Skip to content

Commit

Permalink
Avoiding unnecessary copies
Browse files Browse the repository at this point in the history
  • Loading branch information
Glavo committed Sep 28, 2023
1 parent 8c2b0bc commit ac90491
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/main/java/org/fusesource/jansi/ffm/WindowsAnsiProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,8 @@ private short invertAttributeColors(short attributes) {
}

private void applyCursorPosition() throws IOException {
try (Arena arena = Arena.ofConfined()) {
if (SetConsoleCursorPosition(console, info.cursorPosition().copy(arena)) == 0) {
throw new IOException(WindowsSupport.getLastErrorMessage());
}
if (SetConsoleCursorPosition(console, info.cursorPosition()) == 0) {
throw new IOException(WindowsSupport.getLastErrorMessage());
}
}

Expand Down Expand Up @@ -172,10 +170,10 @@ protected void processEraseScreen(int eraseOption) throws IOException {
console,
info.attributes(),
lengthToEnd,
info.cursorPosition().copy(arena),
info.cursorPosition(),
written);
FillConsoleOutputCharacterW(
console, ' ', lengthToEnd, info.cursorPosition().copy(arena), written);
console, ' ', lengthToEnd, info.cursorPosition(), written);
break;
default:
break;
Expand Down Expand Up @@ -211,10 +209,10 @@ protected void processEraseLine(int eraseOption) throws IOException {
console,
info.attributes(),
lengthToLastCol,
info.cursorPosition().copy(arena),
info.cursorPosition(),
written);
FillConsoleOutputCharacterW(
console, ' ', lengthToLastCol, info.cursorPosition().copy(arena), written);
console, ' ', lengthToLastCol, info.cursorPosition(), written);
break;
default:
break;
Expand Down

0 comments on commit ac90491

Please sign in to comment.