summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorMattias Petersson <mattias.petersson@sonyericsson.com>2010-12-21 10:15:11 +0100
committerDianne Hackborn <hackbod@google.com>2010-12-22 10:42:47 -0800
commit1622eee2e48678b17a4668641957f09213f98905 (patch)
tree73a488b0fda0f7aefc612929ff54f0dc132d5cac /services
parent3ce86481cbde92e2cb6fe3a46cbedd8b2a5c4b48 (diff)
downloadframeworks_base-1622eee2e48678b17a4668641957f09213f98905.zip
frameworks_base-1622eee2e48678b17a4668641957f09213f98905.tar.gz
frameworks_base-1622eee2e48678b17a4668641957f09213f98905.tar.bz2
Improve performance of WindowState.toString()
This fix improves the performance by caching the string that should be returned, and reuse it next time if possible. This will make it faster to switch between activities, approximately half the time to create the new view when changing from landscape to portrait. Also, the time for starting a new application is be reduced as WindowState.toString is being called thousands of times in this case. Change-Id: I2b8b9bc1e251d1af43b6c85f049c01452f2573a2
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/WindowManagerService.java16
1 files changed, 13 insertions, 3 deletions
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index 1b2ddcc..10cceac 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -6003,6 +6003,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) {
@@ -7260,9 +7265,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;
}
}