Skip to content

Commit 408848f

Browse files
committed
Optimize creation of boxed primitives
1 parent 83c4e20 commit 408848f

13 files changed

Lines changed: 35 additions & 35 deletions

File tree

app/src/processing/app/Base.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2381,7 +2381,7 @@ static public int showYesNoCancelQuestion(Editor editor, String title,
23812381
// on macosx, setting the destructive property places this option
23822382
// away from the others at the lefthand side
23832383
pane.putClientProperty("Quaqua.OptionPane.destructiveOption",
2384-
new Integer(2));
2384+
Integer.valueOf(2));
23852385

23862386
JDialog dialog = pane.createDialog(editor, null);
23872387
dialog.setVisible(true);

app/src/processing/app/Preferences.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ static public void unset(String attribute) {
237237

238238
static public boolean getBoolean(String attribute) {
239239
String value = get(attribute); //, null);
240-
return (new Boolean(value)).booleanValue();
240+
return Boolean.parseBoolean(value);
241241

242242
/*
243243
supposedly not needed, because anything besides 'true'

app/src/processing/mode/java/JavaEditor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -577,7 +577,7 @@ public void propertyChange(PropertyChangeEvent e) {
577577
Object value = optionPane.getValue();
578578
if (value.equals(options[0])) {
579579
return jmode.handleExportApplication(sketch);
580-
} else if (value.equals(options[1]) || value.equals(new Integer(-1))) {
580+
} else if (value.equals(options[1]) || value.equals(Integer.valueOf(-1))) {
581581
// closed window by hitting Cancel or ESC
582582
statusNotice("Export to Application canceled.");
583583
}
@@ -832,4 +832,4 @@ public void internalCloseRunner() {
832832
//jmode.handleStop();
833833
handleStop();
834834
}
835-
}
835+
}

core/methods/demo/PApplet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5959,7 +5959,7 @@ static final public boolean parseBoolean(float what) {
59595959
* @return true if 'what' is "true" or "TRUE", false otherwise
59605960
*/
59615961
static final public boolean parseBoolean(String what) {
5962-
return new Boolean(what).booleanValue();
5962+
return Boolean.parseBoolean(what);
59635963
}
59645964

59655965
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -6017,7 +6017,7 @@ static final public boolean[] parseBoolean(float what[]) {
60176017
static final public boolean[] parseBoolean(String what[]) {
60186018
boolean outgoing[] = new boolean[what.length];
60196019
for (int i = 0; i < what.length; i++) {
6020-
outgoing[i] = new Boolean(what[i]).booleanValue();
6020+
outgoing[i] = Boolean.parseBoolean(what[i]);
60216021
}
60226022
return outgoing;
60236023
}

core/src/processing/core/PApplet.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9260,7 +9260,7 @@ static final public boolean parseBoolean(float what) {
92609260
* @return true if 'what' is "true" or "TRUE", false otherwise
92619261
*/
92629262
static final public boolean parseBoolean(String what) {
9263-
return new Boolean(what).booleanValue();
9263+
return Boolean.parseBoolean(what);
92649264
}
92659265

92669266
// . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
@@ -9320,7 +9320,7 @@ static final public boolean[] parseBoolean(float what[]) {
93209320
static final public boolean[] parseBoolean(String what[]) {
93219321
boolean outgoing[] = new boolean[what.length];
93229322
for (int i = 0; i < what.length; i++) {
9323-
outgoing[i] = new Boolean(what[i]).booleanValue();
9323+
outgoing[i] = Boolean.parseBoolean(what[i]);
93249324
}
93259325
return outgoing;
93269326
}

core/src/processing/core/PShapeOBJ.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ static protected void parseMTL(PApplet parent, String path,
335335
// Starting new material.
336336
String mtlname = parts[1];
337337
currentMtl = new OBJMaterial(mtlname);
338-
materialsHash.put(mtlname, new Integer(materials.size()));
338+
materialsHash.put(mtlname, Integer.valueOf(materials.size()));
339339
materials.add(currentMtl);
340340
} else if (parts[0].equals("map_Kd") && parts.length > 1) {
341341
// Loading texture map.

core/src/processing/data/FloatDict.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ protected void create(String what, float much) {
493493
keys = PApplet.expand(keys);
494494
values = PApplet.expand(values);
495495
}
496-
indices.put(what, new Integer(count));
496+
indices.put(what, Integer.valueOf(count));
497497
keys[count] = what;
498498
values[count] = much;
499499
count++;
@@ -540,8 +540,8 @@ public void swap(int a, int b) {
540540
keys[b] = tkey;
541541
values[b] = tvalue;
542542

543-
indices.put(keys[a], new Integer(a));
544-
indices.put(keys[b], new Integer(b));
543+
indices.put(keys[a], Integer.valueOf(a));
544+
indices.put(keys[b], Integer.valueOf(b));
545545
}
546546

547547

core/src/processing/data/IntDict.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ protected void create(String what, int much) {
486486
keys = PApplet.expand(keys);
487487
values = PApplet.expand(values);
488488
}
489-
indices.put(what, new Integer(count));
489+
indices.put(what, Integer.valueOf(count));
490490
keys[count] = what;
491491
values[count] = much;
492492
count++;
@@ -532,8 +532,8 @@ public void swap(int a, int b) {
532532
keys[b] = tkey;
533533
values[b] = tvalue;
534534

535-
indices.put(keys[a], new Integer(a));
536-
indices.put(keys[b], new Integer(b));
535+
indices.put(keys[a], Integer.valueOf(a));
536+
indices.put(keys[b], Integer.valueOf(b));
537537
}
538538

539539

core/src/processing/data/JSONArray.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ protected JSONArray(JSONTokener x) {
168168
public JSONArray(IntList list) {
169169
myArrayList = new ArrayList<Object>();
170170
for (int item : list.values()) {
171-
myArrayList.add(new Integer(item));
171+
myArrayList.add(Integer.valueOf(item));
172172
}
173173
}
174174

@@ -718,7 +718,7 @@ public JSONArray append(String value) {
718718
* @return this.
719719
*/
720720
public JSONArray append(int value) {
721-
this.append(new Integer(value));
721+
this.append(Integer.valueOf(value));
722722
return this;
723723
}
724724

@@ -731,7 +731,7 @@ public JSONArray append(int value) {
731731
* @return this.
732732
*/
733733
public JSONArray append(long value) {
734-
this.append(new Long(value));
734+
this.append(Long.valueOf(value));
735735
return this;
736736
}
737737

@@ -758,7 +758,7 @@ public JSONArray append(float value) {
758758
* @return this.
759759
*/
760760
public JSONArray append(double value) {
761-
Double d = new Double(value);
761+
Double d = value;
762762
JSONObject.testValidity(d);
763763
this.append(d);
764764
return this;
@@ -884,7 +884,7 @@ public JSONArray setString(int index, String value) {
884884
* @see JSONArray#setBoolean(int, boolean)
885885
*/
886886
public JSONArray setInt(int index, int value) {
887-
this.set(index, new Integer(value));
887+
this.set(index, Integer.valueOf(value));
888888
return this;
889889
}
890890

@@ -899,7 +899,7 @@ public JSONArray setInt(int index, int value) {
899899
* @throws JSONException If the index is negative.
900900
*/
901901
public JSONArray setLong(int index, long value) {
902-
return set(index, new Long(value));
902+
return set(index, Long.valueOf(value));
903903
}
904904

905905

@@ -936,7 +936,7 @@ public JSONArray setFloat(int index, float value) {
936936
* not finite.
937937
*/
938938
public JSONArray setDouble(int index, double value) {
939-
return set(index, new Double(value));
939+
return set(index, Double.valueOf(value));
940940
}
941941

942942

core/src/processing/data/JSONObject.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,7 @@ public JSONObject setString(String key, String value) {
11681168
* @see JSONObject#setBoolean(String, boolean)
11691169
*/
11701170
public JSONObject setInt(String key, int value) {
1171-
this.put(key, new Integer(value));
1171+
this.put(key, Integer.valueOf(value));
11721172
return this;
11731173
}
11741174

@@ -1182,7 +1182,7 @@ public JSONObject setInt(String key, int value) {
11821182
* @throws JSONException If the key is null.
11831183
*/
11841184
public JSONObject setLong(String key, long value) {
1185-
this.put(key, new Long(value));
1185+
this.put(key, Long.valueOf(value));
11861186
return this;
11871187
}
11881188

@@ -1494,7 +1494,7 @@ static protected Object stringToValue(String string) {
14941494
} else {
14951495
Long myLong = new Long(string);
14961496
if (myLong.longValue() == myLong.intValue()) {
1497-
return new Integer(myLong.intValue());
1497+
return Integer.valueOf(myLong.intValue());
14981498
} else {
14991499
return myLong;
15001500
}

0 commit comments

Comments
 (0)