Skip to content
Permalink
Browse files
8274680: Remove unnecessary conversion to String in java.desktop
Reviewed-by: pbansal, jdv, serb, kizune
  • Loading branch information
turbanoff authored and mrserb committed Oct 6, 2021
1 parent 986ee5d commit 8a4d2b4aa76e6aae1cb27f476c6cc71dcd9779f0
Showing 16 changed files with 50 additions and 69 deletions.
@@ -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 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 @@ void write(ImageOutputStream ios) throws IOException {

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 @@ void print() {
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();
/*
@@ -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 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 @@ void write(ImageOutputStream ios) throws IOException {

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 @@ IIOMetadataNode getNativeNode() {
}

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();
/*
@@ -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 @@ void write(ImageOutputStream ios) throws IOException {

void print() {
printTag("DRI");
System.out.println("Interval: "
+ Integer.toString(restartInterval));
System.out.println("Interval: " + restartInterval);
}
}
@@ -617,8 +617,7 @@ void print() {
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: ");
@@ -979,14 +979,14 @@ public IIOMetadataNode getStandardDataNode() {
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 IIOMetadataNode getStandardTransparencyNode() {
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));
}
@@ -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 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 String getValueAsString(int index) {
// 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 String getValueAsString(int index) {
// 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:
@@ -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 @@ private void fireValueChanged() {
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 void setValueIsAdjusting(boolean isAdjusting) {
*/
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 void moveLeadSelectionIndex(int leadIndex) {
* 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
@@ -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 @@ private void createSpringDescription(StringBuilder sb, Spring spring,
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 SequentialGroup addPreferredGap(JComponent comp1,
* @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 SequentialGroup addPreferredGap(ComponentPlacement type) {
* @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 @@ private int updateSize(LayoutStyle p, ComponentSpring sourceSpring,

String getMatchDescription() {
if (targets != null) {
return "leading: " + targets.toString();
return "leading: " + targets;
}
if (sources != null) {
return "trailing: " + sources.toString();
return "trailing: " + sources;
}
return "--";
}
@@ -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 int[] getChildIndices() {
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) {
@@ -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 String toString() {
buf = "bar ";
break;
}
buf = buf + "tab @" + String.valueOf(position);
buf = buf + "tab @" + position;
if (leader != LEAD_NONE)
buf = buf + " (w/leaders)";
return buf;
@@ -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 @@ public void setValueIsAdjusting(boolean isAdjusting) {

public String toString() {
String s = ((getValueIsAdjusting()) ? "~" : "=") + value.toString();
return getClass().getName() + " " + Integer.toString(hashCode()) + " " + s;
return getClass().getName() + " " + hashCode() + " " + s;
}

/**
@@ -499,7 +499,7 @@ public void setAnchorSelectionIndex(int anchorIndex) {
* 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,
@@ -1174,10 +1174,9 @@ public String toString() {
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();
@@ -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];
@@ -613,7 +613,7 @@ protected void startDoc() throws PrinterException {
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");
@@ -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 Object clone() {

/**
* 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 String toString() {

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(',');

1 comment on commit 8a4d2b4

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 8a4d2b4 Oct 6, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.