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

Commit 3b10aea5 authored by Dianne Hackborn's avatar Dianne Hackborn Committed by Android Code Review
Browse files

Merge "Improve performance of WindowState.toString()"

parents 749c627f 33b43247
Loading
Loading
Loading
Loading
+13 −3
Original line number Diff line number Diff line
@@ -6005,6 +6005,11 @@ public class WindowManagerService extends IWindowManager.Stub
        // Input channel
        InputChannel mInputChannel;
        
        // Used to improve performance of toString()
        String mStringNameCache;
        CharSequence mLastTitle;
        boolean mWasPaused;

        WindowState(Session s, IWindow c, WindowToken token,
               WindowState attachedWindow, WindowManager.LayoutParams a,
               int viewVisibility) {
@@ -7262,9 +7267,14 @@ public class WindowManagerService extends IWindowManager.Stub

        @Override
        public String toString() {
            return "Window{"
                + Integer.toHexString(System.identityHashCode(this))
                + " " + mAttrs.getTitle() + " paused=" + mToken.paused + "}";
            if (mStringNameCache == null || mLastTitle != mAttrs.getTitle()
                    || mWasPaused != mToken.paused) {
                mLastTitle = mAttrs.getTitle();
                mWasPaused = mToken.paused;
                mStringNameCache = "Window{" + Integer.toHexString(System.identityHashCode(this))
                        + " " + mLastTitle + " paused=" + mWasPaused + "}";
            }
            return mStringNameCache;
        }
    }