From 6358f6e567422c8a5e880af36bec9ea798cc2cd4 Mon Sep 17 00:00:00 2001 From: Kevin Lamonte Date: Wed, 8 Mar 2017 11:54:11 -0500 Subject: [PATCH] Performance tweaks --- src/jexer/TApplication.java | 3 +++ src/jexer/bits/Cell.java | 7 +++++-- src/jexer/bits/CellAttributes.java | 10 +++++----- src/jexer/io/SwingScreen.java | 3 ++- 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/jexer/TApplication.java b/src/jexer/TApplication.java index e9a7a44..0a2ab19 100644 --- a/src/jexer/TApplication.java +++ b/src/jexer/TApplication.java @@ -772,6 +772,9 @@ public class TApplication implements Runnable { // wait until either the backend or the consumer threads have // something to do. try { + if (debugThreads) { + System.err.println("sleep " + timeout + " millis"); + } synchronized (this) { this.wait(timeout); } diff --git a/src/jexer/bits/Cell.java b/src/jexer/bits/Cell.java index d4d78ba..957ac76 100644 --- a/src/jexer/bits/Cell.java +++ b/src/jexer/bits/Cell.java @@ -101,8 +101,11 @@ public final class Cell extends CellAttributes { } Cell that = (Cell) rhs; - return (super.equals(rhs) - && (ch == that.ch)); + + if (ch == that.ch) { + return super.equals(rhs); + } + return false; } /** diff --git a/src/jexer/bits/CellAttributes.java b/src/jexer/bits/CellAttributes.java index e889e89..43e0b22 100644 --- a/src/jexer/bits/CellAttributes.java +++ b/src/jexer/bits/CellAttributes.java @@ -231,13 +231,13 @@ public class CellAttributes { } CellAttributes that = (CellAttributes) rhs; - return ((bold == that.bold) - && (blink == that.blink) + return ((foreColor == that.foreColor) + && (backColor == that.backColor) + && (bold == that.bold) && (reverse == that.reverse) && (underline == that.underline) - && (protect == that.protect) - && (foreColor == that.foreColor) - && (backColor == that.backColor)); + && (blink == that.blink) + && (protect == that.protect)); } /** diff --git a/src/jexer/io/SwingScreen.java b/src/jexer/io/SwingScreen.java index 2471010..4a602b3 100644 --- a/src/jexer/io/SwingScreen.java +++ b/src/jexer/io/SwingScreen.java @@ -451,10 +451,12 @@ public final class SwingScreen extends Screen { // Prevent updates to the screen's data from the TApplication // threads. synchronized (screen) { + /* System.err.printf("bounds %s X %d %d Y %d %d\n", bounds, xCellMin, xCellMax, yCellMin, yCellMax); */ + Cell lCellColor = new Cell(); for (int y = yCellMin; y < yCellMax; y++) { for (int x = xCellMin; x < xCellMax; x++) { @@ -469,7 +471,6 @@ public final class SwingScreen extends Screen { || lCell.isBlink() || reallyCleared) { - Cell lCellColor = new Cell(); lCellColor.setTo(lCell); // Check for reverse -- 2.27.0