aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
authorJean Chalard <jchalard@google.com>2014-07-01 05:52:28 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-07-01 05:52:28 +0000
commitdca55d7c972d3753078d18d8a611470c239a94b4 (patch)
tree919cf62ebb9103e3320d6f99df10153d3c359184 /java/src
parent3ab0124289295021cebf4e5088dc641839415b2a (diff)
parent943e91ffbd1edc88bcd815997f8b4d591d02dc7e (diff)
downloadlatinime-dca55d7c972d3753078d18d8a611470c239a94b4.tar.gz
latinime-dca55d7c972d3753078d18d8a611470c239a94b4.tar.xz
latinime-dca55d7c972d3753078d18d8a611470c239a94b4.zip
am 943e91ff: Merge "[SD6] Inline a constant and remove logic become useless"
* commit '943e91ffbd1edc88bcd815997f8b4d591d02dc7e': [SD6] Inline a constant and remove logic become useless
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/RichInputConnection.java29
1 files changed, 8 insertions, 21 deletions
diff --git a/java/src/com/android/inputmethod/latin/RichInputConnection.java b/java/src/com/android/inputmethod/latin/RichInputConnection.java
index 96bf17b5c..5e0dafa57 100644
--- a/java/src/com/android/inputmethod/latin/RichInputConnection.java
+++ b/java/src/com/android/inputmethod/latin/RichInputConnection.java
@@ -626,7 +626,6 @@ public final class RichInputConnection {
* @return a range containing the text surrounding the cursor
*/
public TextRange getWordRangeAtCursor(final int[] sortedSeparators) {
- final int additionalPrecedingWordsCount = 0;
mIC = mParent.getCurrentInputConnection();
if (mIC == null) {
return null;
@@ -639,29 +638,17 @@ public final class RichInputConnection {
return null;
}
- // Going backward, alternate skipping non-separators and separators until enough words
- // have been read.
- int count = additionalPrecedingWordsCount;
+ // Going backward, find the first breaking point (separator)
int startIndexInBefore = before.length();
- boolean isStoppingAtWhitespace = true; // toggles to indicate what to stop at
- while (true) { // see comments below for why this is guaranteed to halt
- while (startIndexInBefore > 0) {
- final int codePoint = Character.codePointBefore(before, startIndexInBefore);
- if (isStoppingAtWhitespace == isSeparator(codePoint, sortedSeparators)) {
- break; // inner loop
- }
- --startIndexInBefore;
- if (Character.isSupplementaryCodePoint(codePoint)) {
- --startIndexInBefore;
- }
+ while (startIndexInBefore > 0) {
+ final int codePoint = Character.codePointBefore(before, startIndexInBefore);
+ if (isSeparator(codePoint, sortedSeparators)) {
+ break;
}
- // isStoppingAtWhitespace is true every other time through the loop,
- // so additionalPrecedingWordsCount is guaranteed to become < 0, which
- // guarantees outer loop termination
- if (isStoppingAtWhitespace && (--count < 0)) {
- break; // outer loop
+ --startIndexInBefore;
+ if (Character.isSupplementaryCodePoint(codePoint)) {
+ --startIndexInBefore;
}
- isStoppingAtWhitespace = !isStoppingAtWhitespace;
}
// Find last word separator after the cursor