diff options
| author | Romain Guy <romainguy@google.com> | 2013-06-03 22:38:07 +0000 |
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2013-06-03 22:38:07 +0000 |
| commit | 36e337f971649b00841cc3a0e69869769229af14 (patch) | |
| tree | 2a4aef624379dc684fa583983305dc13b9a558b5 /core/java | |
| parent | 64f2227bbc603d31b36ea7375525888c8a2b7698 (diff) | |
| parent | 31f0544293fdfc134452c630b4813adc97d05ee7 (diff) | |
Merge "Remove unnecessary lock to save 1 allocation per TextView"
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/widget/TextView.java | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/core/java/android/widget/TextView.java b/core/java/android/widget/TextView.java index b1692d7900d4..4410c2e8d812 100644 --- a/core/java/android/widget/TextView.java +++ b/core/java/android/widget/TextView.java @@ -548,7 +548,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener private InputFilter[] mFilters = NO_FILTERS; private volatile Locale mCurrentSpellCheckerLocaleCache; - private final ReentrantLock mCurrentTextServicesLocaleLock = new ReentrantLock(); // It is possible to have a selection even when mEditor is null (programmatically set, like when // a link is pressed). These highlight-related fields do not go in mEditor. @@ -8023,16 +8022,13 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener } private void updateTextServicesLocaleAsync() { + // AsyncTask.execute() uses a serial executor which means we don't have + // to lock around updateTextServicesLocaleLocked() to prevent it from + // being executed n times in parallel. AsyncTask.execute(new Runnable() { @Override public void run() { - if (mCurrentTextServicesLocaleLock.tryLock()) { - try { - updateTextServicesLocaleLocked(); - } finally { - mCurrentTextServicesLocaleLock.unlock(); - } - } + updateTextServicesLocaleLocked(); } }); } |
