From 0a064a5d88c5cdc03f8ef13a2f7b6b506b9cbdfa Mon Sep 17 00:00:00 2001
From: Jean Chalard <jchalard@google.com>
Date: Fri, 26 Jul 2013 19:50:19 +0900
Subject: [PATCH] Small optimization

Bug: 8864306
Change-Id: Ic8eecd64eff6a1150a90b9f5ec9ebbc5f1d2a6a9
---
 .../inputmethod/latin/RichInputConnection.java     | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 5cda1e14b8..d07fa47d62 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -571,12 +571,13 @@ public final class RichInputConnection {
     }
 
     public boolean isCursorTouchingWord(final SettingsValues settingsValues) {
-        final CharSequence before = getTextBeforeCursor(1, 0);
-        final CharSequence after = getTextAfterCursor(1, 0);
-        if (!TextUtils.isEmpty(before) && !settingsValues.isWordSeparator(before.charAt(0))
-                && !settingsValues.isWordConnector(before.charAt(0))) {
+        final int codePointBeforeCursor = getCodePointBeforeCursor();
+        if (Constants.NOT_A_CODE != codePointBeforeCursor
+                && !settingsValues.isWordSeparator(codePointBeforeCursor)
+                && !settingsValues.isWordConnector(codePointBeforeCursor)) {
             return true;
         }
+        final CharSequence after = getTextAfterCursor(1, 0);
         if (!TextUtils.isEmpty(after) && !settingsValues.isWordSeparator(after.charAt(0))
                 && !settingsValues.isWordConnector(after.charAt(0))) {
             return true;
@@ -586,9 +587,8 @@ public final class RichInputConnection {
 
     public void removeTrailingSpace() {
         if (DEBUG_BATCH_NESTING) checkBatchEdit();
-        final CharSequence lastOne = getTextBeforeCursor(1, 0);
-        if (lastOne != null && lastOne.length() == 1
-                && lastOne.charAt(0) == Constants.CODE_SPACE) {
+        final int codePointBeforeCursor = getCodePointBeforeCursor();
+        if (Constants.CODE_SPACE == codePointBeforeCursor) {
             deleteSurroundingText(1, 0);
         }
     }
-- 
GitLab