Tuesday, January 3, 2012

Re: System.arraycopy limits and Function.prototype.apply



On Monday, January 2, 2012 12:05:33 PM UTC+1, cko wrote:

So the problem is invoking a varargs function (in our case
Array.splice) with the content of the src array as individual function
arguments.

Why is System.arraycopy() implemented like this?

How would you have done it? Array.splice/Array.slice surely is the fastest emulation of System.arraycopy.
 
Is this a known limitation?

Not to my knowledge; probably no-one ever tried copying that many elements.
 
Are there recommended workarounds?

Something like that maybe?

while (length > MAX_ELEMENTS_PER_COPY) {
  System.arraycopy(src, srcPos, dest, destPost, Math.max(length, MAX_ELEMENTS_PER_COPY));
  srcPos += MAX_ELEMENTS_PER_COPY;
  destPost += MAX_ELEMENTS_PER_COPY;
  length -= MAX_ELEMENTS_PER_COPY;
}

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/oggx0PzSh_EJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment