问题描述
我知道,一个常见的性能重构是由 System.arraycopy。
来代替简单的为
的
我想请教一下:
-
在究竟system.arraycopy开始变得有意义(考虑到它是一个本地方法调用)。是否抄袭小东西说,< 32有什么优势?
-
这是我的IM pression,或者是它不只是可以复制(有效的)一个周期是这个样子arraycopy:
为(INT J = 0; J&2; ++ j)条{
VPR [M] [S + j]的[I] = VR [J]。
}
System.arrayCopy
很可能是最快的方法来复制一个数组,但它不会使深层副本
这还不能做你的第二个问题更为复杂的例子。
I'm aware that a common performance refactoring is to replace simple for
's by System.arraycopy.
I want to ask about:
When exactly does system.arraycopy begin to make sense (considering it's a native method call). Does copying small things say, < 32 have any advantage?
Is it my impression, or is it not simply possible to copy (efficiently) a cycle like this with arraycopy:
for (int j = 0; j < 2; ++j) { vpr[m][s + j][i] = vr[j]; }
System.arrayCopy
is likely the fastest way to copy an array, but it does not make deep copies.
It also cannot do the more complex example in your second question.
这篇关于多维数组高效System.arraycopy的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!