Merge pull request #2826 from federicobond/primitive-optimization

Optimize creation of boxed primitives
This commit is contained in:
Ben Fry
2014-08-28 11:02:02 -04:00
13 changed files with 35 additions and 35 deletions
+1 -1
View File
@@ -2381,7 +2381,7 @@ public class Base {
// on macosx, setting the destructive property places this option
// away from the others at the lefthand side
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
new Integer(2));
Integer.valueOf(2));
JDialog dialog = pane.createDialog(editor, null);
dialog.setVisible(true);
+1 -1
View File
@@ -237,7 +237,7 @@ public class Preferences {
static public boolean getBoolean(String attribute) {
String value = get(attribute); //, null);
return (new Boolean(value)).booleanValue();
return Boolean.parseBoolean(value);
/*
supposedly not needed, because anything besides 'true'
+2 -2
View File
@@ -577,7 +577,7 @@ public class JavaEditor extends Editor {
Object value = optionPane.getValue();
if (value.equals(options[0])) {
return jmode.handleExportApplication(sketch);
} else if (value.equals(options[1]) || value.equals(new Integer(-1))) {
} else if (value.equals(options[1]) || value.equals(Integer.valueOf(-1))) {
// closed window by hitting Cancel or ESC
statusNotice("Export to Application canceled.");
}
@@ -832,4 +832,4 @@ public class JavaEditor extends Editor {
//jmode.handleStop();
handleStop();
}
}
}
+2 -2
View File
@@ -5959,7 +5959,7 @@ public class PApplet extends Applet
* @return true if 'what' is "true" or "TRUE", false otherwise
*/
static final public boolean parseBoolean(String what) {
return new Boolean(what).booleanValue();
return Boolean.parseBoolean(what);
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -6017,7 +6017,7 @@ public class PApplet extends Applet
static final public boolean[] parseBoolean(String what[]) {
boolean outgoing[] = new boolean[what.length];
for (int i = 0; i < what.length; i++) {
outgoing[i] = new Boolean(what[i]).booleanValue();
outgoing[i] = Boolean.parseBoolean(what[i]);
}
return outgoing;
}
+2 -2
View File
@@ -9260,7 +9260,7 @@ public class PApplet extends Applet
* @return true if 'what' is "true" or "TRUE", false otherwise
*/
static final public boolean parseBoolean(String what) {
return new Boolean(what).booleanValue();
return Boolean.parseBoolean(what);
}
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -9320,7 +9320,7 @@ public class PApplet extends Applet
static final public boolean[] parseBoolean(String what[]) {
boolean outgoing[] = new boolean[what.length];
for (int i = 0; i < what.length; i++) {
outgoing[i] = new Boolean(what[i]).booleanValue();
outgoing[i] = Boolean.parseBoolean(what[i]);
}
return outgoing;
}
+1 -1
View File
@@ -335,7 +335,7 @@ public class PShapeOBJ extends PShape {
// Starting new material.
String mtlname = parts[1];
currentMtl = new OBJMaterial(mtlname);
materialsHash.put(mtlname, new Integer(materials.size()));
materialsHash.put(mtlname, Integer.valueOf(materials.size()));
materials.add(currentMtl);
} else if (parts[0].equals("map_Kd") && parts.length > 1) {
// Loading texture map.
+3 -3
View File
@@ -493,7 +493,7 @@ public class FloatDict {
keys = PApplet.expand(keys);
values = PApplet.expand(values);
}
indices.put(what, new Integer(count));
indices.put(what, Integer.valueOf(count));
keys[count] = what;
values[count] = much;
count++;
@@ -540,8 +540,8 @@ public class FloatDict {
keys[b] = tkey;
values[b] = tvalue;
indices.put(keys[a], new Integer(a));
indices.put(keys[b], new Integer(b));
indices.put(keys[a], Integer.valueOf(a));
indices.put(keys[b], Integer.valueOf(b));
}
+3 -3
View File
@@ -486,7 +486,7 @@ public class IntDict {
keys = PApplet.expand(keys);
values = PApplet.expand(values);
}
indices.put(what, new Integer(count));
indices.put(what, Integer.valueOf(count));
keys[count] = what;
values[count] = much;
count++;
@@ -532,8 +532,8 @@ public class IntDict {
keys[b] = tkey;
values[b] = tvalue;
indices.put(keys[a], new Integer(a));
indices.put(keys[b], new Integer(b));
indices.put(keys[a], Integer.valueOf(a));
indices.put(keys[b], Integer.valueOf(b));
}
+7 -7
View File
@@ -168,7 +168,7 @@ public class JSONArray {
public JSONArray(IntList list) {
myArrayList = new ArrayList<Object>();
for (int item : list.values()) {
myArrayList.add(new Integer(item));
myArrayList.add(Integer.valueOf(item));
}
}
@@ -718,7 +718,7 @@ public class JSONArray {
* @return this.
*/
public JSONArray append(int value) {
this.append(new Integer(value));
this.append(Integer.valueOf(value));
return this;
}
@@ -731,7 +731,7 @@ public class JSONArray {
* @return this.
*/
public JSONArray append(long value) {
this.append(new Long(value));
this.append(Long.valueOf(value));
return this;
}
@@ -758,7 +758,7 @@ public class JSONArray {
* @return this.
*/
public JSONArray append(double value) {
Double d = new Double(value);
Double d = value;
JSONObject.testValidity(d);
this.append(d);
return this;
@@ -884,7 +884,7 @@ public class JSONArray {
* @see JSONArray#setBoolean(int, boolean)
*/
public JSONArray setInt(int index, int value) {
this.set(index, new Integer(value));
this.set(index, Integer.valueOf(value));
return this;
}
@@ -899,7 +899,7 @@ public class JSONArray {
* @throws JSONException If the index is negative.
*/
public JSONArray setLong(int index, long value) {
return set(index, new Long(value));
return set(index, Long.valueOf(value));
}
@@ -936,7 +936,7 @@ public class JSONArray {
* not finite.
*/
public JSONArray setDouble(int index, double value) {
return set(index, new Double(value));
return set(index, Double.valueOf(value));
}
+3 -3
View File
@@ -1168,7 +1168,7 @@ public class JSONObject {
* @see JSONObject#setBoolean(String, boolean)
*/
public JSONObject setInt(String key, int value) {
this.put(key, new Integer(value));
this.put(key, Integer.valueOf(value));
return this;
}
@@ -1182,7 +1182,7 @@ public class JSONObject {
* @throws JSONException If the key is null.
*/
public JSONObject setLong(String key, long value) {
this.put(key, new Long(value));
this.put(key, Long.valueOf(value));
return this;
}
@@ -1494,7 +1494,7 @@ public class JSONObject {
} else {
Long myLong = new Long(string);
if (myLong.longValue() == myLong.intValue()) {
return new Integer(myLong.intValue());
return Integer.valueOf(myLong.intValue());
} else {
return myLong;
}
+3 -3
View File
@@ -279,7 +279,7 @@ public class StringDict {
keys = PApplet.expand(keys);
values = PApplet.expand(values);
}
indices.put(key, new Integer(count));
indices.put(key, Integer.valueOf(count));
keys[count] = key;
values[count] = value;
count++;
@@ -325,8 +325,8 @@ public class StringDict {
keys[b] = tkey;
values[b] = tvalue;
indices.put(keys[a], new Integer(a));
indices.put(keys[b], new Integer(b));
indices.put(keys[a], Integer.valueOf(a));
indices.put(keys[b], Integer.valueOf(b));
}
@@ -248,7 +248,7 @@ public class OSCByteArrayToJavaConverter {
intBytes[2] = bytes[streamPosition++];
intBytes[3] = bytes[streamPosition++];
BigInteger intBits = new BigInteger(intBytes);
return new Integer(intBits.intValue());
return Integer.valueOf(intBits.intValue());
}
/**
+6 -6
View File
@@ -11,8 +11,8 @@ public class OSCSender {
{
OSCPortOut sender = new OSCPortOut(InetAddress.getByName("localhost"), port);
ArrayList<Object> args = new ArrayList<Object>();
args.add(new Integer(index));
args.add(new Float(val));
args.add(Integer.valueOf(index));
args.add(Float.valueOf(val));
OSCMessage msg = new OSCMessage("/tm_change_float", args);
try {
sender.send(msg);
@@ -25,8 +25,8 @@ public class OSCSender {
{
OSCPortOut sender = new OSCPortOut(InetAddress.getByName("localhost"), port);
ArrayList<Object> args = new ArrayList<Object>();
args.add(new Integer(index));
args.add(new Integer(val));
args.add(Integer.valueOf(index));
args.add(Integer.valueOf(val));
OSCMessage msg = new OSCMessage("/tm_change_int", args);
try {
sender.send(msg);
@@ -40,8 +40,8 @@ public class OSCSender {
{
OSCPortOut sender = new OSCPortOut(InetAddress.getByName("localhost"), port);
ArrayList<Object> args = new ArrayList<Object>();
args.add(new Integer(index));
args.add(new Long(val));
args.add(Integer.valueOf(index));
args.add(Long.valueOf(val));
OSCMessage msg = new OSCMessage("/tm_change_long", args);
try {
sender.send(msg);