Skip to content

Commit aabfd2f

Browse files
committed
Optimize map iteration in CombinedFormatUtils
Modify the loop iterating over `attributeMap` in `formatAttributeMap` to use `entrySet()` rather than `keySet()` followed by `get()`. This eliminates redundant map lookups.
1 parent e62ee58 commit aabfd2f

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

app/src/main/java/helium314/keyboard/latin/utils/CombinedFormatUtils.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ public static String formatAttributeMap(final HashMap<String, String> attributeM
3535
if (attributeMap.containsKey(DictionaryHeader.DICTIONARY_ID_KEY)) {
3636
builder.append(attributeMap.get(DictionaryHeader.DICTIONARY_ID_KEY));
3737
}
38-
for (final String key : attributeMap.keySet()) {
38+
for (final java.util.Map.Entry<String, String> entry : attributeMap.entrySet()) {
39+
final String key = entry.getKey();
3940
if (key.equals(DictionaryHeader.DICTIONARY_ID_KEY)) {
4041
continue;
4142
}
42-
final String value = attributeMap.get(key);
43+
final String value = entry.getValue();
4344
builder.append("," + key + "=" + value);
4445
}
4546
builder.append("\n");

0 commit comments

Comments
 (0)