8274680: Remove unnecessary conversion to String in java.desktop

Reviewed-by: pbansal, jdv, serb, kizune
This commit is contained in:
Andrey Turbanov 2021-10-06 02:53:09 +00:00 committed by Sergey Bylokhov
parent 986ee5d0bf
commit 8a4d2b4aa7
16 changed files with 50 additions and 69 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, 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
@ -33,7 +33,6 @@ import javax.imageio.plugins.jpeg.JPEGHuffmanTable;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@ -119,8 +118,7 @@ class DHTMarkerSegment extends MarkerSegment {
void print() {
printTag("DHT");
System.out.println("Num tables: "
+ Integer.toString(tables.size()));
System.out.println("Num tables: " + tables.size());
for (int i= 0; i<tables.size(); i++) {
Htable table = tables.get(i);
table.print();
@ -232,7 +230,7 @@ class DHTMarkerSegment extends MarkerSegment {
System.out.println("Huffman Table");
System.out.println("table class: "
+ ((tableClass == 0) ? "DC":"AC"));
System.out.println("table id: " + Integer.toString(tableID));
System.out.println("table id: " + tableID);
(new JPEGHuffmanTable(numCodes, values)).toString();
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, 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
@ -34,7 +34,6 @@ import javax.imageio.plugins.jpeg.JPEGQTable;
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.Iterator;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
@ -112,8 +111,7 @@ class DQTMarkerSegment extends MarkerSegment {
void print() {
printTag("DQT");
System.out.println("Num tables: "
+ Integer.toString(tables.size()));
System.out.println("Num tables: " + tables.size());
for (int i= 0; i<tables.size(); i++) {
Qtable table = tables.get(i);
table.print();
@ -288,9 +286,8 @@ class DQTMarkerSegment extends MarkerSegment {
}
void print() {
System.out.println("Table id: " + Integer.toString(tableID));
System.out.println("Element precision: "
+ Integer.toString(elementPrecision));
System.out.println("Table id: " + tableID);
System.out.println("Element precision: " + elementPrecision);
(new JPEGQTable(data)).toString();
/*

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2001, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2021, 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
@ -77,7 +77,6 @@ class DRIMarkerSegment extends MarkerSegment {
void print() {
printTag("DRI");
System.out.println("Interval: "
+ Integer.toString(restartInterval));
System.out.println("Interval: " + restartInterval);
}
}

View File

@ -617,8 +617,7 @@ class JFIFMarkerSegment extends MarkerSegment {
printTag("JFIF");
System.out.print("Version ");
System.out.print(majorVersion);
System.out.println(".0"
+ Integer.toString(minorVersion));
System.out.println(".0" + minorVersion);
System.out.print("Resolution units: ");
System.out.println(resUnits);
System.out.print("X density: ");

View File

@ -979,14 +979,14 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
sbits = Integer.toString(sBIT_grayBits);
} else { // sBIT_colorType == PNGImageReader.PNG_COLOR_RGB ||
// sBIT_colorType == PNGImageReader.PNG_COLOR_RGB_ALPHA
sbits = Integer.toString(sBIT_redBits) + " " +
Integer.toString(sBIT_greenBits) + " " +
Integer.toString(sBIT_blueBits);
sbits = sBIT_redBits + " " +
sBIT_greenBits + " " +
sBIT_blueBits;
}
if (sBIT_colorType == PNGImageReader.PNG_COLOR_GRAY_ALPHA ||
sBIT_colorType == PNGImageReader.PNG_COLOR_RGB_ALPHA) {
sbits += " " + Integer.toString(sBIT_alphaBits);
sbits += " " + sBIT_alphaBits;
}
node.setAttribute("value", sbits);
@ -1134,9 +1134,9 @@ public class PNGMetadata extends IIOMetadata implements Cloneable {
node = new IIOMetadataNode("TransparentColor");
if (tRNS_colorType == PNGImageReader.PNG_COLOR_RGB) {
node.setAttribute("value",
Integer.toString(tRNS_red) + " " +
Integer.toString(tRNS_green) + " " +
Integer.toString(tRNS_blue));
tRNS_red + " " +
tRNS_green + " " +
tRNS_blue);
} else if (tRNS_colorType == PNGImageReader.PNG_COLOR_GRAY) {
node.setAttribute("value", Integer.toString(tRNS_gray));
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2005, 2017, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2005, 2021, 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
@ -28,7 +28,6 @@ import java.util.StringTokenizer;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import com.sun.imageio.plugins.tiff.TIFFFieldNode;
import com.sun.imageio.plugins.tiff.TIFFIFD;
/**
* A class representing a field in a TIFF 6.0 Image File Directory.
@ -1304,14 +1303,10 @@ public final class TIFFField implements Cloneable {
// If the denominator is a non-zero integral divisor
// of the numerator then convert the fraction to be
// with respect to a unity denominator.
srationalString =
Integer.toString(ivalue[0] / ivalue[1]) + "/1";
srationalString = (ivalue[0] / ivalue[1]) + "/1";
} else {
// Use the values directly.
srationalString =
Integer.toString(ivalue[0]) +
"/" +
Integer.toString(ivalue[1]);
srationalString = ivalue[0] + "/" + ivalue[1];
}
return srationalString;
case TIFFTag.TIFF_RATIONAL:
@ -1321,14 +1316,10 @@ public final class TIFFField implements Cloneable {
// If the denominator is a non-zero integral divisor
// of the numerator then convert the fraction to be
// with respect to a unity denominator.
rationalString =
Long.toString(lvalue[0] / lvalue[1]) + "/1";
rationalString = (lvalue[0] / lvalue[1]) + "/1";
} else {
// Use the values directly.
rationalString =
Long.toString(lvalue[0]) +
"/" +
Long.toString(lvalue[1]);
rationalString = lvalue[0] + "/" + lvalue[1];
}
return rationalString;
default:

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@ -230,7 +230,7 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable,
if (lastAdjustedIndex == MIN) {
return;
}
/* If getValueAdjusting() is true, (eg. during a drag opereration)
/* If getValueAdjusting() is true, (eg. during a drag operation)
* record the bounds of the changes so that, when the drag finishes (and
* setValueAdjusting(false) is called) we can post a single event
* with bounds covering all of these individual adjustments.
@ -738,7 +738,7 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable,
*/
public String toString() {
String s = ((getValueIsAdjusting()) ? "~" : "=") + value.toString();
return getClass().getName() + " " + Integer.toString(hashCode()) + " " + s;
return getClass().getName() + " " + hashCode() + " " + s;
}
/**
@ -825,7 +825,7 @@ public class DefaultListSelectionModel implements ListSelectionModel, Cloneable,
* anchor and the new lead are either all selected or all deselected.
* If the value at the anchor index is selected, first clear all the
* values in the range [anchor, oldLeadIndex], then select all the values
* values in the range [anchor, newLeadIndex], where oldLeadIndex is the old
* in the range [anchor, newLeadIndex], where oldLeadIndex is the old
* leadIndex and newLeadIndex is the new one.
* <p>
* If the value at the anchor index is not selected, do the same thing in

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2006, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2006, 2021, 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
@ -1230,7 +1230,7 @@ public class GroupLayout implements LayoutManager2 {
String padding = "";
if (spring instanceof ComponentSpring) {
ComponentSpring cSpring = (ComponentSpring)spring;
origin = Integer.toString(cSpring.getOrigin()) + " ";
origin = cSpring.getOrigin() + " ";
String name = cSpring.getComponent().getName();
if (name != null) {
origin = "name=" + name + ", ";
@ -1885,7 +1885,7 @@ public class GroupLayout implements LayoutManager2 {
* @param comp1 the first component
* @param comp2 the second component
* @param type the type of gap
* @param pref the preferred size of the grap; one of
* @param pref the preferred size of the gap; one of
* {@code DEFAULT_SIZE} or a value &gt;= 0
* @param max the maximum size of the gap; one of
* {@code DEFAULT_SIZE}, {@code PREFERRED_SIZE}
@ -1944,7 +1944,7 @@ public class GroupLayout implements LayoutManager2 {
* @param type the type of gap; one of
* {@code LayoutStyle.ComponentPlacement.RELATED} or
* {@code LayoutStyle.ComponentPlacement.UNRELATED}
* @param pref the preferred size of the grap; one of
* @param pref the preferred size of the gap; one of
* {@code DEFAULT_SIZE} or a value &gt;= 0
* @param max the maximum size of the gap; one of
* {@code DEFAULT_SIZE}, {@code PREFERRED_SIZE}
@ -3506,10 +3506,10 @@ public class GroupLayout implements LayoutManager2 {
String getMatchDescription() {
if (targets != null) {
return "leading: " + targets.toString();
return "leading: " + targets;
}
if (sources != null) {
return "trailing: " + sources.toString();
return "trailing: " + sources;
}
return "--";
}

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@ -294,14 +294,13 @@ public class TreeModelEvent extends EventObject {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append(getClass().getName() + " " +
Integer.toString(hashCode()));
sb.append(getClass().getName() + " " + hashCode());
if(path != null)
sb.append(" path " + path);
if(childIndices != null) {
sb.append(" indices [ ");
for(int counter = 0; counter < childIndices.length; counter++)
sb.append(Integer.toString(childIndices[counter])+ " ");
sb.append(childIndices[counter] + " ");
sb.append("]");
}
if(children != null) {

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1997, 2021, 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
@ -181,7 +181,7 @@ public class TabStop implements Serializable {
buf = "bar ";
break;
}
buf = buf + "tab @" + String.valueOf(position);
buf = buf + "tab @" + position;
if (leader != LEAD_NONE)
buf = buf + " (w/leaders)";
return buf;

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 1998, 2021, 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
@ -456,7 +456,7 @@ class OptionListModel<E> extends DefaultListModel<E> implements ListSelectionMod
public String toString() {
String s = ((getValueIsAdjusting()) ? "~" : "=") + value.toString();
return getClass().getName() + " " + Integer.toString(hashCode()) + " " + s;
return getClass().getName() + " " + hashCode() + " " + s;
}
/**
@ -499,7 +499,7 @@ class OptionListModel<E> extends DefaultListModel<E> implements ListSelectionMod
* anchor and the new lead are either all selected or all deselected.
* If the value at the anchor index is selected, first clear all the
* values in the range [anchor, oldLeadIndex], then select all the values
* values in the range [anchor, newLeadIndex], where oldLeadIndex is the old
* in the range [anchor, newLeadIndex], where oldLeadIndex is the old
* leadIndex and newLeadIndex is the new one.
* <p>
* If the value at the anchor index is not selected, do the same thing in reverse,

View File

@ -1174,10 +1174,9 @@ public class DefaultTreeSelectionModel implements Cloneable, Serializable, TreeS
sb.append(getClass().getName() + " " + hashCode() + " [ ");
for(int counter = 0; counter < selCount; counter++) {
if(rows != null)
sb.append(selection[counter].toString() + "@" +
Integer.toString(rows[counter])+ " ");
sb.append(selection[counter] + "@" + rows[counter] + " ");
else
sb.append(selection[counter].toString() + " ");
sb.append(selection[counter] + " ");
}
sb.append("]");
return sb.toString();

View File

@ -48,13 +48,12 @@ final class RendererContext extends ReentrantContext implements MarlinConst {
* @return new RendererContext instance
*/
static RendererContext createContext() {
return new RendererContext("ctx"
+ Integer.toString(CTX_COUNT.getAndIncrement()));
return new RendererContext("ctx" + CTX_COUNT.getAndIncrement());
}
// Smallest object used as Cleaner's parent reference
private final Object cleanerObj;
// dirty flag indicating an exception occured during pipeline in pathTo()
// dirty flag indicating an exception occurred during pipeline in pathTo()
boolean dirty = false;
// shared data
final double[] double6 = new double[6];

View File

@ -613,7 +613,7 @@ public class PSPrinterJob extends RasterPrinterJob {
int cnt = Integer.parseInt(mFontProps.getProperty("font.num", "9"));
for (int i = 0; i < cnt; i++){
mPSStream.println(" /" + mFontProps.getProperty
("font." + String.valueOf(i), "Courier ISOF"));
("font." + i, "Courier ISOF"));
}
}
mPSStream.println("] D");

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2021, 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
@ -470,7 +470,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
/**
* Merges the contents of this Style with that of the passed in Style,
* returning the resulting merged syle. Properties of this
* returning the resulting merged style. Properties of this
* <code>DefaultSynthStyle</code> will take precedence over those of the
* passed in <code>DefaultSynthStyle</code>. For example, if this
* style specifics a non-null font, the returned style will have its
@ -887,7 +887,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable {
sb.append(super.toString()).append(',');
sb.append("state=").append(Integer.toString(state)).append(',');
sb.append("state=").append(state).append(',');
sb.append("font=").append(font).append(',');

View File

@ -106,7 +106,7 @@ final class WDesktopProperties {
private synchronized void setBooleanProperty(String key, boolean value) {
assert( key != null );
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine(key + "=" + String.valueOf(value));
log.fine(key + "=" + value);
}
map.put(key, Boolean.valueOf(value));
}
@ -117,7 +117,7 @@ final class WDesktopProperties {
private synchronized void setIntegerProperty(String key, int value) {
assert( key != null );
if (log.isLoggable(PlatformLogger.Level.FINE)) {
log.fine(key + "=" + String.valueOf(value));
log.fine(key + "=" + value);
}
map.put(key, Integer.valueOf(value));
}