Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 36e337f9 authored by Romain Guy's avatar Romain Guy Committed by Android (Google) Code Review
Browse files

Merge "Remove unnecessary lock to save 1 allocation per TextView"

parents 64f2227b 31f05442
Loading
Loading
Loading
Loading
+4 −8
Original line number Original line Diff line number Diff line
@@ -548,7 +548,6 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    private InputFilter[] mFilters = NO_FILTERS;
    private InputFilter[] mFilters = NO_FILTERS;


    private volatile Locale mCurrentSpellCheckerLocaleCache;
    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
    // 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.
    // 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() {
    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() {
        AsyncTask.execute(new Runnable() {
            @Override
            @Override
            public void run() {
            public void run() {
                if (mCurrentTextServicesLocaleLock.tryLock()) {
                    try {
                updateTextServicesLocaleLocked();
                updateTextServicesLocaleLocked();
                    } finally {
                        mCurrentTextServicesLocaleLock.unlock();
                    }
                }
            }
            }
        });
        });
    }
    }