Skip to content

Commit 0834d17

Browse files
committed
Store array/list size in a local variable for performance
1 parent d27d699 commit 0834d17

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

library/src/main/java/com/loopj/android/http/RequestParams.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -512,12 +512,14 @@ private List<BasicNameValuePair> getParamsList(String key, Object value) {
512512
}
513513
} else if (value instanceof List) {
514514
List list = (List) value;
515-
for (int nestedValueIndex = 0; nestedValueIndex < list.size(); nestedValueIndex++) {
515+
int listSize = list.size();
516+
for (int nestedValueIndex = 0; nestedValueIndex < listSize; nestedValueIndex++) {
516517
params.addAll(getParamsList(String.format("%s[%d]", key, nestedValueIndex), list.get(nestedValueIndex)));
517518
}
518519
} else if (value instanceof Object[]) {
519520
Object[] array = (Object[]) value;
520-
for (int nestedValueIndex = 0; nestedValueIndex < array.length; nestedValueIndex++) {
521+
int arrayLength = array.length;
522+
for (int nestedValueIndex = 0; nestedValueIndex < arrayLength; nestedValueIndex++) {
521523
params.addAll(getParamsList(String.format("%s[%d]", key, nestedValueIndex), array[nestedValueIndex]));
522524
}
523525
} else if (value instanceof Set) {

0 commit comments

Comments
 (0)