Use PooledLambda.obtainMessage() when possible
As its JavaDoc says, in most of cases PooledLambda.obtainMessage() is a better choice than PooledLambda.obtainRunnable(). If PooledLambda.obtainRunnable() is really necessary, let's make sure to call recycleOnUse() whenever possible. Test: presubmit Change-Id: I3dbe500f49c0df187f2ffefd11c71836696dfd4e
This commit is contained in:
@@ -1541,7 +1541,7 @@ public final class ActivityThread extends ClientTransactionHandler {
|
||||
|
||||
public void scheduleTrimMemory(int level) {
|
||||
final Runnable r = PooledLambda.obtainRunnable(ActivityThread::handleTrimMemory,
|
||||
ActivityThread.this, level);
|
||||
ActivityThread.this, level).recycleOnUse();
|
||||
// Schedule trimming memory after drawing the frame to minimize jank-risk.
|
||||
Choreographer choreographer = Choreographer.getMainThreadInstance();
|
||||
if (choreographer != null) {
|
||||
|
||||
@@ -1197,10 +1197,9 @@ public final class UiAutomation {
|
||||
}
|
||||
if (listener != null) {
|
||||
// Calling out only without a lock held.
|
||||
mLocalCallbackHandler.post(PooledLambda.obtainRunnable(
|
||||
mLocalCallbackHandler.sendMessage(PooledLambda.obtainMessage(
|
||||
OnAccessibilityEventListener::onAccessibilityEvent,
|
||||
listener, AccessibilityEvent.obtain(event))
|
||||
.recycleOnUse());
|
||||
listener, AccessibilityEvent.obtain(event)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user