SWIGTYPE pointer value assignment is slow

138 Views Asked by At

I am using SWIG to wrap certain c++ code for Java through JNI.

In Java I have

SWIGTYPE_p_int A = new example.new_array(n);
for (int i = 0; i< n ; i++)
     example.setitem(A,i,2*i);

and I pass the array to C++ , but when n is large and I have to do this 1000 times, it becomes very slow ....

Is there a faster method to do this? Specifically: Is there any way to create an array in Java and pass the whole thing to c++ at once?

Thanks

0

There are 0 best solutions below