From: Po Lu Date: Tue, 11 Jun 2024 06:39:40 +0000 (+0800) Subject: Eliminate some redundant synchronization on Android X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=86b0df779224472aed64888a45cf7b5e074b58c7;p=emacs.git Eliminate some redundant synchronization on Android * java/org/gnu/emacs/EmacsService.java (resetIC): Return on all versions of Android if the connection need not be reset. * java/org/gnu/emacs/EmacsView.java (getICMode, setICMode): Remove needless synchronization. (cherry picked from commit 677f082b0feda295e6a710b5dac6040f57cfad8b) --- diff --git a/java/org/gnu/emacs/EmacsService.java b/java/org/gnu/emacs/EmacsService.java index 2dcaad16e50..cfe9e42de4d 100644 --- a/java/org/gnu/emacs/EmacsService.java +++ b/java/org/gnu/emacs/EmacsService.java @@ -899,11 +899,19 @@ public final class EmacsService extends Service if (DEBUG_IC) Log.d (TAG, "resetIC: " + window + ", " + icMode); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU - && (oldMode = window.view.getICMode ()) == icMode - /* Don't do this if there is currently no input - connection. */ - && oldMode != IC_MODE_NULL) + oldMode = window.view.getICMode (); + + /* If it's not necessary to reset the input connection for ICMODE to + take effect, return immediately. */ + if (oldMode == IC_MODE_NULL && icMode == IC_MODE_NULL) + { + if (DEBUG_IC) + Log.d (TAG, "resetIC: redundant invocation ignored"); + return; + } + + if (oldMode == icMode + && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { if (DEBUG_IC) Log.d (TAG, "resetIC: calling invalidateInput"); diff --git a/java/org/gnu/emacs/EmacsView.java b/java/org/gnu/emacs/EmacsView.java index 244a3a02166..4a505b3c0dc 100644 --- a/java/org/gnu/emacs/EmacsView.java +++ b/java/org/gnu/emacs/EmacsView.java @@ -891,13 +891,13 @@ public final class EmacsView extends ViewGroup return true; } - public synchronized void + public void setICMode (int icMode) { this.icMode = icMode; } - public synchronized int + public int getICMode () { return icMode;