# HG changeset patch # User serb # Date 1392644005 -14400 # Node ID 6a715c2969cf1d290bea26146a66901baacffc17 # Parent 1c729daf92a0f49014c10c48e642bcdeb5ab6ba0 8034068: Label.toString performance improvement Reviewed-by: anthony, art diff -r 1c729daf92a0 -r 6a715c2969cf jdk/src/share/classes/java/awt/Component.java --- a/jdk/src/share/classes/java/awt/Component.java Mon Feb 17 17:15:28 2014 +0400 +++ b/jdk/src/share/classes/java/awt/Component.java Mon Feb 17 17:33:25 2014 +0400 @@ -26,10 +26,10 @@ import java.io.PrintStream; import java.io.PrintWriter; +import java.util.Objects; import java.util.Vector; import java.util.Locale; import java.util.EventListener; -import java.util.Iterator; import java.util.HashSet; import java.util.Map; import java.util.Set; @@ -50,8 +50,6 @@ import java.beans.PropertyChangeListener; import java.beans.PropertyChangeSupport; import java.beans.Transient; -import java.awt.event.InputMethodListener; -import java.awt.event.InputMethodEvent; import java.awt.im.InputContext; import java.awt.im.InputMethodRequests; import java.awt.dnd.DropTarget; @@ -8131,18 +8129,12 @@ * @since JDK1.0 */ protected String paramString() { - String thisName = getName(); - String str = (thisName != null? thisName : "") + "," + x + "," + y + "," + width + "x" + height; - if (!isValid()) { - str += ",invalid"; - } - if (!visible) { - str += ",hidden"; - } - if (!enabled) { - str += ",disabled"; - } - return str; + final String thisName = Objects.toString(getName(), ""); + final String invalid = isValid() ? "" : ",invalid"; + final String hidden = visible ? "" : ",hidden"; + final String disabled = enabled ? "" : ",disabled"; + return thisName + ',' + x + ',' + y + ',' + width + 'x' + height + + invalid + hidden + disabled; } /** @@ -8151,7 +8143,7 @@ * @since JDK1.0 */ public String toString() { - return getClass().getName() + "[" + paramString() + "]"; + return getClass().getName() + '[' + paramString() + ']'; } /** diff -r 1c729daf92a0 -r 6a715c2969cf jdk/src/share/classes/java/awt/Label.java --- a/jdk/src/share/classes/java/awt/Label.java Mon Feb 17 17:15:28 2014 +0400 +++ b/jdk/src/share/classes/java/awt/Label.java Mon Feb 17 17:33:25 2014 +0400 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -272,13 +272,13 @@ * @return the parameter string of this label */ protected String paramString() { - String str = ",align="; + String align = ""; switch (alignment) { - case LEFT: str += "left"; break; - case CENTER: str += "center"; break; - case RIGHT: str += "right"; break; + case LEFT: align = "left"; break; + case CENTER: align = "center"; break; + case RIGHT: align = "right"; break; } - return super.paramString() + str + ",text=" + text; + return super.paramString() + ",align=" + align + ",text=" + text; } /**