For Android development in general, is it more expensive to do the following: (Example 1)
for(int x=0; x < largeObjectCollection.size(); x++){
largeObjectCollection.get(x).SomeValueOne = "Sample Value 1";
largeObjectCollection.get(x).SomeValueTwo = "Sample Value 2";
largeObjectCollection.get(x).SomeValueThree = "Sample Value 3" ;
//Continues on to over 30 properties...
}
Over this implementation (Example 2)
for(int x=0; x < largeObjectCollection.size(); x++){
SampleObjectIns myObject = largeObjectCollection.get(x);
myObject.SomeValueOne = "Sample Value 1";
myObject.SomeValueTwo = "Sample Value 2";
myObject.SomeValueThree = "Sample Value 3" ;
//Continues on to over 30 properties...
}
I couldn't find any break down of performance implications when using .get()
multiple times instead of creating a new instance of that object each iteration.
I'm thinking that .get()
doesn't use much in terms of resources since the position of the element is already known, but when dealing with many properties is it best to just fetch that object once as shown in example two?