Small optimization to eliminate a >0 check in RichInputConnection.

Change-Id: Ibdf97726008c1f94c970461196ba445ce328a8cb
main
Tom Ouyang 2015-06-24 12:00:04 -07:00
parent ecea6a6113
commit 96640a110b
1 changed files with 3 additions and 4 deletions

View File

@ -126,7 +126,7 @@ public final class RichInputConnection implements PrivateCommandPerformer {
/** /**
* The timestamp of the last slow InputConnection operation * The timestamp of the last slow InputConnection operation
*/ */
private long mLastSlowInputConnectionTime = 0; private long mLastSlowInputConnectionTime = -SLOW_INPUTCONNECTION_PERSIST_MS;
public RichInputConnection(final InputMethodService parent) { public RichInputConnection(final InputMethodService parent) {
mParent = parent; mParent = parent;
@ -143,13 +143,12 @@ public final class RichInputConnection implements PrivateCommandPerformer {
* calling InputConnection methods that trigger an IPC round-trip (e.g., getTextAfterCursor). * calling InputConnection methods that trigger an IPC round-trip (e.g., getTextAfterCursor).
*/ */
public boolean hasSlowInputConnection() { public boolean hasSlowInputConnection() {
return mLastSlowInputConnectionTime > 0 && return (SystemClock.uptimeMillis() - mLastSlowInputConnectionTime)
(SystemClock.uptimeMillis() - mLastSlowInputConnectionTime)
<= SLOW_INPUTCONNECTION_PERSIST_MS; <= SLOW_INPUTCONNECTION_PERSIST_MS;
} }
public void onStartInput() { public void onStartInput() {
mLastSlowInputConnectionTime = 0; mLastSlowInputConnectionTime = -SLOW_INPUTCONNECTION_PERSIST_MS;
} }
private void checkConsistencyForDebug() { private void checkConsistencyForDebug() {