Skip to content

Commit

Permalink
Less StringBuilder allocation nonsense (#455)
Browse files Browse the repository at this point in the history
* Less StringBuilder allocation nonsense
  • Loading branch information
mitchej123 authored Feb 15, 2024
1 parent af320a6 commit dea0241
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/main/java/codechicken/nei/NEIClientConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.function.Function;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -441,8 +442,11 @@ public static void unloadWorld() {
}
}

private static final Map<String, String> keySettings = new HashMap<>();

public static int getKeyBinding(String string) {
return getSetting("keys." + string).getIntValue(Keyboard.KEY_NONE);
final String key = keySettings.computeIfAbsent(string, (s) -> "keys." + s);
return getSetting(key).getIntValue(Keyboard.KEY_NONE);
}

public static void setDefaultKeyBinding(String string, int key) {
Expand Down

0 comments on commit dea0241

Please sign in to comment.