Humphrey bogart wav files5/26/2023 ![]() We are looking at the implementation code from a specific version of Java. There are a couple of flaws in this analysis. So the performance comparison is not straightforward. ![]() But you can see (from the code quoted above) that pyOf will in some cases use reflection to create the new array. Therefore System.arraycopy is on the face of it should not be slower 2 than pyOf. ![]() The other point is that pyOf uses System.arraycopy under the hood. That is significantly slower than a simple C-style memcopy of the array contents. In this case, the foo and bar arrays have different base types, so the implementation of arraycopy has to check the type of every reference copied to make sure that it is actually a reference to a String instance. System.arraycopy(foo, 0, bar, 0, bar.length) Consider this example: Object foo = new Object While System.arraycopy is implemented natively, and is therefore could be 1 faster than a Java loop, it is not always as fast as you might expect.
0 Comments
Leave a Reply. |