Skip to content

Commit 3b10aea

Browse files
Dianne HackbornAndroid Code Review
authored andcommitted
Merge "Improve performance of WindowState.toString()"
2 parents 749c627 + 33b4324 commit 3b10aea

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

services/java/com/android/server/WindowManagerService.java

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6005,6 +6005,11 @@ private final class WindowState implements WindowManagerPolicy.WindowState {
60056005
// Input channel
60066006
InputChannel mInputChannel;
60076007

6008+
// Used to improve performance of toString()
6009+
String mStringNameCache;
6010+
CharSequence mLastTitle;
6011+
boolean mWasPaused;
6012+
60086013
WindowState(Session s, IWindow c, WindowToken token,
60096014
WindowState attachedWindow, WindowManager.LayoutParams a,
60106015
int viewVisibility) {
@@ -7262,9 +7267,14 @@ String makeInputChannelName() {
72627267

72637268
@Override
72647269
public String toString() {
7265-
return "Window{"
7266-
+ Integer.toHexString(System.identityHashCode(this))
7267-
+ " " + mAttrs.getTitle() + " paused=" + mToken.paused + "}";
7270+
if (mStringNameCache == null || mLastTitle != mAttrs.getTitle()
7271+
|| mWasPaused != mToken.paused) {
7272+
mLastTitle = mAttrs.getTitle();
7273+
mWasPaused = mToken.paused;
7274+
mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this))
7275+
+ " " + mLastTitle + " paused=" + mWasPaused + "}";
7276+
}
7277+
return mStringNameCache;
72687278
}
72697279
}
72707280

0 commit comments

Comments
 (0)