Skip to content

Commit

Permalink
IJPL-159869 Improve performance of decodeUsingGraphicalState
Browse files Browse the repository at this point in the history
Create the char array only once.
Previously, we created the array in StringBuilder and also had to expand it on overflow.
Also, we created an array inside `StringBuilder.toString()` and then in `String.toCharArray()`.
  • Loading branch information
KonstantinHudyakov committed Aug 8, 2024
1 parent 4cf430a commit 3e760c3
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions core/src/com/jediterm/terminal/model/JediTerminal.java
Original file line number Diff line number Diff line change
Expand Up @@ -167,12 +167,11 @@ public void writeDoubleByte(final char[] bytesOfChar) throws UnsupportedEncoding


private char[] decodeUsingGraphicalState(String string) {
StringBuilder result = new StringBuilder();
for (char c : string.toCharArray()) {
result.append(myGraphicSetState.map(c));
char[] chars = string.toCharArray();
for (int i = 0; i < chars.length; i++) {
chars[i] = myGraphicSetState.map(chars[i]);
}

return result.toString().toCharArray();
return chars;
}

public void writeUnwrappedString(String string) {
Expand Down

0 comments on commit 3e760c3

Please sign in to comment.