Skip to content

Commit 1c40701

Browse files
nonelseuerceg
authored andcommitted
Reorder length checks for readability
1 parent 14db413 commit 1c40701

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

Adjust/adjust/src/main/java/com/adjust/sdk/SharedPreferencesManager.java

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,20 @@ public synchronized void saveRawReferrer(final String rawReferrer, final long cl
8181
}
8282

8383
JSONArray rawReferrerArray = getRawReferrerArray();
84-
if (rawReferrerArray.length() > REFERRERS_COUNT - 1) {
85-
// Initial move for those who have more than REFERRERS_COUNT stored already.
86-
// Cut the array and leave it with only REFERRERS_COUNT elements.
87-
if (rawReferrerArray.length() > REFERRERS_COUNT) {
88-
JSONArray tempReferrerArray = new JSONArray();
89-
for (int i = 0; i < REFERRERS_COUNT; i += 1) {
90-
tempReferrerArray.put(rawReferrerArray.get(i));
91-
}
92-
saveRawReferrerArray(tempReferrerArray);
93-
return;
84+
85+
// Initial move for those who have more than REFERRERS_COUNT stored already.
86+
// Cut the array and leave it with only REFERRERS_COUNT elements.
87+
if (rawReferrerArray.length() > REFERRERS_COUNT) {
88+
JSONArray tempReferrerArray = new JSONArray();
89+
for (int i = 0; i < REFERRERS_COUNT; i += 1) {
90+
tempReferrerArray.put(rawReferrerArray.get(i));
9491
}
95-
// There are exactly REFERRERS_COUNT saved referrers, do nothing.
92+
saveRawReferrerArray(tempReferrerArray);
93+
return;
94+
}
95+
96+
// There are exactly REFERRERS_COUNT saved referrers, do nothing.
97+
if (rawReferrerArray.length() == REFERRERS_COUNT) {
9698
return;
9799
}
98100

0 commit comments

Comments
 (0)