不是从b中获取c的内存位置,而是从标题中获取b的内存位置,将a.b.c的内存位置存储为d会更快吗?一个例子比我的问题的描述更好。
假设我有以下javascript代码:
for (int i = 0; i < 100; i++) {
object1[index].name.value1 = object2[index].name.value1;
object1[index].name.value2 = object2[index].name.value2;
object1[index].name.value3 = object2[index].name.value3;
object1[index].name.value4 = object2[index].name.value4;
object1[index].name.value5 = object2[index].name.value5;
}
如果我改变它会运行得更快我保存了对对象[index] .name的引用,还是这样运行等同于使它毫无意义?这看起来如下:
for (int i = 0; i < 100; i++) {
Object example1 = object[index].name;
Object example2 = object2[index].name;
example1.value1 = example2.value1;
example1.value2 = example2.value2;
example1.value3 = example2.value3;
example1.value4 = example2.value4;
example1.value5 = example2.value5;
}
第二个示例会运行得更快,更慢,还是与第一个示例相同,为什么?