am 654b0a9c: Merge "Small optimization"

* commit '654b0a9c16b133019d5c68548d799a44164e7724':
  Small optimization
This commit is contained in:
Jean Chalard 2013-07-26 04:35:03 -07:00 committed by Android Git Automerger
commit 35541a727e

View file

@ -571,12 +571,13 @@ public final class RichInputConnection {
} }
public boolean isCursorTouchingWord(final SettingsValues settingsValues) { public boolean isCursorTouchingWord(final SettingsValues settingsValues) {
final CharSequence before = getTextBeforeCursor(1, 0); final int codePointBeforeCursor = getCodePointBeforeCursor();
final CharSequence after = getTextAfterCursor(1, 0); if (Constants.NOT_A_CODE != codePointBeforeCursor
if (!TextUtils.isEmpty(before) && !settingsValues.isWordSeparator(before.charAt(0)) && !settingsValues.isWordSeparator(codePointBeforeCursor)
&& !settingsValues.isWordConnector(before.charAt(0))) { && !settingsValues.isWordConnector(codePointBeforeCursor)) {
return true; return true;
} }
final CharSequence after = getTextAfterCursor(1, 0);
if (!TextUtils.isEmpty(after) && !settingsValues.isWordSeparator(after.charAt(0)) if (!TextUtils.isEmpty(after) && !settingsValues.isWordSeparator(after.charAt(0))
&& !settingsValues.isWordConnector(after.charAt(0))) { && !settingsValues.isWordConnector(after.charAt(0))) {
return true; return true;
@ -586,9 +587,8 @@ public final class RichInputConnection {
public void removeTrailingSpace() { public void removeTrailingSpace() {
if (DEBUG_BATCH_NESTING) checkBatchEdit(); if (DEBUG_BATCH_NESTING) checkBatchEdit();
final CharSequence lastOne = getTextBeforeCursor(1, 0); final int codePointBeforeCursor = getCodePointBeforeCursor();
if (lastOne != null && lastOne.length() == 1 if (Constants.CODE_SPACE == codePointBeforeCursor) {
&& lastOne.charAt(0) == Constants.CODE_SPACE) {
deleteSurroundingText(1, 0); deleteSurroundingText(1, 0);
} }
} }