From 005623c76884decc8085c1bd300bd50dad4af22c Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sun, 14 Sep 2014 21:00:26 -0300 Subject: [PATCH 1/6] Avoid boxing/unboxing when parsing primitive --- app/src/processing/app/Preferences.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/processing/app/Preferences.java b/app/src/processing/app/Preferences.java index 1a47fd35f..809765702 100644 --- a/app/src/processing/app/Preferences.java +++ b/app/src/processing/app/Preferences.java @@ -64,7 +64,7 @@ public class Preferences { * Windows XP needs 66, and my Ubuntu machine needs 80+, so 80 seems proper. */ static public int BUTTON_WIDTH = - Integer.valueOf(Language.text("preferences.button.width")); + Integer.parseInt(Language.text("preferences.button.width")); /** height of the EditorHeader, EditorToolbar, and EditorStatus */ static final int GRID_SIZE = 32; From c2c1f1a2164a07a07c6332fe58a0ec76625a5d8a Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sun, 14 Sep 2014 21:01:36 -0300 Subject: [PATCH 2/6] Avoid inefficient use of new String(String) --- core/src/processing/core/PApplet.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index 20c708866..a6ee0bb92 100755 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -9049,7 +9049,7 @@ public class PApplet extends Applet //} if (splitCount == 0) { String splits[] = new String[1]; - splits[0] = new String(value); + splits[0] = value; return splits; } //int pieceCount = splitCount + 1; From 69b5953203e6681a3f1a1ecdb49ade9014bbd809 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sun, 14 Sep 2014 21:02:29 -0300 Subject: [PATCH 3/6] Use valueOf factory method instead of constructor --- core/src/processing/core/PShapeSVG.java | 8 ++++---- core/src/processing/data/JSONObject.java | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/src/processing/core/PShapeSVG.java b/core/src/processing/core/PShapeSVG.java index bf7d3ef19..da95d7eed 100644 --- a/core/src/processing/core/PShapeSVG.java +++ b/core/src/processing/core/PShapeSVG.java @@ -1811,7 +1811,7 @@ public class PShapeSVG extends PShape { namedGlyphs.put(fg.name, fg); } if (fg.unicode != 0) { - unicodeGlyphs.put(new Character(fg.unicode), fg); + unicodeGlyphs.put(Character.valueOf(fg.unicode), fg); } } glyphs[glyphCount++] = fg; @@ -1845,7 +1845,7 @@ public class PShapeSVG extends PShape { char[] c = str.toCharArray(); for (int i = 0; i < c.length; i++) { // call draw on each char (pulling it w/ the unicode table) - FontGlyph fg = unicodeGlyphs.get(new Character(c[i])); + FontGlyph fg = unicodeGlyphs.get(Character.valueOf(c[i])); if (fg != null) { fg.draw(g); // add horizAdvX/unitsPerEm to the x coordinate along the way @@ -1863,7 +1863,7 @@ public class PShapeSVG extends PShape { float s = size / face.unitsPerEm; g.translate(x, y); g.scale(s, -s); - FontGlyph fg = unicodeGlyphs.get(new Character(c)); + FontGlyph fg = unicodeGlyphs.get(Character.valueOf(c)); if (fg != null) g.shape(fg); g.popMatrix(); } @@ -1874,7 +1874,7 @@ public class PShapeSVG extends PShape { char[] c = str.toCharArray(); for (int i = 0; i < c.length; i++) { // call draw on each char (pulling it w/ the unicode table) - FontGlyph fg = unicodeGlyphs.get(new Character(c[i])); + FontGlyph fg = unicodeGlyphs.get(Character.valueOf(c[i])); if (fg != null) { w += (float) fg.horizAdvX / face.unitsPerEm; } diff --git a/core/src/processing/data/JSONObject.java b/core/src/processing/data/JSONObject.java index 705ee3ff8..f5f02541e 100644 --- a/core/src/processing/data/JSONObject.java +++ b/core/src/processing/data/JSONObject.java @@ -1492,7 +1492,7 @@ public class JSONObject { return d; } } else { - Long myLong = new Long(string); + Long myLong = Long.valueOf(string); if (myLong.longValue() == myLong.intValue()) { return Integer.valueOf(myLong.intValue()); } else { From 73f46c2d5b35add511e9215a5c01c245a1f710b2 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sun, 14 Sep 2014 21:04:44 -0300 Subject: [PATCH 4/6] Add missing static modifier to inner classes --- core/src/processing/core/PApplet.java | 2 +- core/src/processing/data/Table.java | 2 +- core/src/processing/opengl/PJOGL.java | 2 +- core/src/processing/opengl/PShader.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/processing/core/PApplet.java b/core/src/processing/core/PApplet.java index a6ee0bb92..3a3534750 100755 --- a/core/src/processing/core/PApplet.java +++ b/core/src/processing/core/PApplet.java @@ -2637,7 +2637,7 @@ public class PApplet extends Applet // protected int eventCount; - class InternalEventQueue { + static class InternalEventQueue { protected Event queue[] = new Event[10]; protected int offset; protected int count; diff --git a/core/src/processing/data/Table.java b/core/src/processing/data/Table.java index 6b89f5af7..b9f7db424 100644 --- a/core/src/processing/data/Table.java +++ b/core/src/processing/data/Table.java @@ -3627,7 +3627,7 @@ public class Table { // . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . - class HashMapBlows { + static class HashMapBlows { HashMap dataToIndex = new HashMap(); ArrayList indexToData = new ArrayList(); diff --git a/core/src/processing/opengl/PJOGL.java b/core/src/processing/opengl/PJOGL.java index 1ecb147cb..355c56b17 100644 --- a/core/src/processing/opengl/PJOGL.java +++ b/core/src/processing/opengl/PJOGL.java @@ -1195,7 +1195,7 @@ public class PJOGL extends PGL { } - protected class Tessellator implements PGL.Tessellator { + protected static class Tessellator implements PGL.Tessellator { protected GLUtessellator tess; protected TessellatorCallback callback; protected GLUCallback gluCallback; diff --git a/core/src/processing/opengl/PShader.java b/core/src/processing/opengl/PShader.java index b34351c87..aad807194 100644 --- a/core/src/processing/opengl/PShader.java +++ b/core/src/processing/opengl/PShader.java @@ -1438,7 +1438,7 @@ public class PShader implements PConstants { // // Class to store a user-specified value for a uniform parameter // in the shader - protected class UniformValue { + protected static class UniformValue { static final int INT1 = 0; static final int INT2 = 1; static final int INT3 = 2; From 0da8a76f95bab7f2e6acbef712388392c424f62b Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sun, 14 Sep 2014 21:46:20 -0300 Subject: [PATCH 5/6] Remove unused PresentMode.device instance variable --- app/src/processing/mode/java/PresentMode.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/app/src/processing/mode/java/PresentMode.java b/app/src/processing/mode/java/PresentMode.java index 05ada7d9d..dc0f1dd11 100644 --- a/app/src/processing/mode/java/PresentMode.java +++ b/app/src/processing/mode/java/PresentMode.java @@ -49,11 +49,6 @@ public class PresentMode { //JMenu preferencesMenu; static JComboBox selector; - /** - * Index of the currently selected display to be used for present mode. - */ - static GraphicsDevice device; - static { GraphicsEnvironment environment = @@ -75,7 +70,6 @@ public class PresentMode { selector.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int index = selector.getSelectedIndex(); - //device = devices[index]; Preferences.setInteger("run.present.display", index + 1); } }); From 0852e0e64dc3bf0e30624672d45b9dcd38135db6 Mon Sep 17 00:00:00 2001 From: Federico Bond Date: Sun, 14 Sep 2014 22:43:33 -0300 Subject: [PATCH 6/6] Add volatile modifier to ColorSelector.selector --- app/src/processing/app/tools/ColorSelector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/processing/app/tools/ColorSelector.java b/app/src/processing/app/tools/ColorSelector.java index f3bf693f7..b36a6ae12 100644 --- a/app/src/processing/app/tools/ColorSelector.java +++ b/app/src/processing/app/tools/ColorSelector.java @@ -43,7 +43,7 @@ public class ColorSelector implements Tool { * Only create one instance, otherwise we'll have dozens of animation * threads going if you open/close a lot of editor windows. */ - static ColorChooser selector; + private static volatile ColorChooser selector; private Editor editor;