GeezerVison is showing github.com — Replace instances of StringBuffer with StringBuilder · Dreadchild/processing@64c401a
File treeExpand file treeCollapse file tree Open diff view settings build/shared/tools/MovieMaker/src/ch/randelshofer/gui/datatransfer src/processing/mode/experimental
Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: app/src/antlr/ExtendedCommonASTWithHiddenTokens.java +23-25Lines changed: 23 additions & 25 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -37,7 +37,7 @@ public void initialize(AST ast) { | 37 | 37 | public String getHiddenAfterString() { | 38 | 38 |
| 39 | 39 | CommonHiddenStreamToken t; | 40 | | - StringBuffer hiddenAfterString = new StringBuffer(100); | | 40 | + StringBuilder hiddenAfterString = new StringBuilder(100); | 41 | 41 |
| 42 | 42 | for ( t = hiddenAfter ; t != null ; t = t.getHiddenAfter() ) { | 43 | 43 | hiddenAfterString.append(t.getText()); | @@ -66,7 +66,7 @@ public String getHiddenBeforeString() { | 66 | 66 |
| 67 | 67 | // dump that list | 68 | 68 |
| 69 | | - StringBuffer hiddenBeforeString = new StringBuffer(100); | | 69 | + StringBuilder hiddenBeforeString = new StringBuilder(100); | 70 | 70 |
| 71 | 71 | for ( CommonHiddenStreamToken t = child; t != null ; | 72 | 72 | t = t.getHiddenAfter() ) { | @@ -76,31 +76,29 @@ public String getHiddenBeforeString() { | 76 | 76 | return hiddenBeforeString.toString(); | 77 | 77 | } | 78 | 78 |
| 79 | | - public void xmlSerializeNode(Writer out) | 80 | | - throws IOException { | 81 | | - StringBuffer buf = new StringBuffer(100); | 82 | | - buf.append("<"); | 83 | | - buf.append(getClass().getName() + " "); | 84 | | - | 85 | | - buf.append("hiddenBeforeString=\"" + | 86 | | - encode(getHiddenBeforeString()) + | 87 | | - "\" text=\"" + encode(getText()) + "\" type=\"" + | 88 | | - getType() + "\" hiddenAfterString=\"" + | 89 | | - encode(getHiddenAfterString()) + "\"/>"); | 90 | | - out.write(buf.toString()); | | 79 | + public void xmlSerializeNode(Writer out) throws IOException { | | 80 | + StringBuilder sb = new StringBuilder(100); | | 81 | + sb.append("<"); | | 82 | + sb.append(getClass().getName() + " "); | | 83 | + | | 84 | + sb.append("hiddenBeforeString=\"" + | | 85 | + encode(getHiddenBeforeString()) + | | 86 | + "\" text=\"" + encode(getText()) + "\" type=\"" + | | 87 | + getType() + "\" hiddenAfterString=\"" + | | 88 | + encode(getHiddenAfterString()) + "\"/>"); | | 89 | + out.write(sb.toString()); | 91 | 90 | } | 92 | 91 |
| 93 | | - public void xmlSerializeRootOpen(Writer out) | 94 | | - throws IOException { | 95 | | - StringBuffer buf = new StringBuffer(100); | 96 | | - buf.append("<"); | 97 | | - buf.append(getClass().getName() + " "); | 98 | | - buf.append("hiddenBeforeString=\"" + | 99 | | - encode(getHiddenBeforeString()) + | 100 | | - "\" text=\"" + encode(getText()) + "\" type=\"" + | 101 | | - getType() + "\" hiddenAfterString=\"" + | 102 | | - encode(getHiddenAfterString()) + "\">\n"); | 103 | | - out.write(buf.toString()); | | 92 | + public void xmlSerializeRootOpen(Writer out) throws IOException { | | 93 | + StringBuilder sb = new StringBuilder(100); | | 94 | + sb.append("<"); | | 95 | + sb.append(getClass().getName() + " "); | | 96 | + sb.append("hiddenBeforeString=\"" + | | 97 | + encode(getHiddenBeforeString()) + | | 98 | + "\" text=\"" + encode(getText()) + "\" type=\"" + | | 99 | + getType() + "\" hiddenAfterString=\"" + | | 100 | + encode(getHiddenAfterString()) + "\">\n"); | | 101 | + out.write(sb.toString()); | 104 | 102 | } | 105 | 103 |
| 106 | 104 | public void xmlSerializeRootClose(Writer out) | |
Collapse file Copy file name to clipboardExpand all lines: app/src/processing/app/Base.java +5-12Lines changed: 5 additions & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -2780,17 +2780,12 @@ public boolean accept(File dir, String name) { | 2780 | 2780 | static public String contentsToClassPath(File folder) { | 2781 | 2781 | if (folder == null) return ""; | 2782 | 2782 |
| 2783 | | - StringBuffer abuffer = new StringBuffer(); | | 2783 | + StringBuilder sb = new StringBuilder(); | 2784 | 2784 | String sep = System.getProperty("path.separator"); | 2785 | 2785 |
| 2786 | 2786 | try { | 2787 | 2787 | String path = folder.getCanonicalPath(); | 2788 | 2788 |
| 2789 | | -// disabled as of 0136 | 2790 | | - // add the folder itself in case any unzipped files | 2791 | | -// abuffer.append(sep); | 2792 | | -// abuffer.append(path); | 2793 | | -// | 2794 | 2789 | // When getting the name of this folder, make sure it has a slash | 2795 | 2790 | // after it, so that the names of sub-items can be added. | 2796 | 2791 | if (!path.endsWith(File.separator)) { | @@ -2805,17 +2800,15 @@ static public String contentsToClassPath(File folder) { | 2805 | 2800 |
| 2806 | 2801 | if (list[i].toLowerCase().endsWith(".jar") || | 2807 | 2802 | list[i].toLowerCase().endsWith(".zip")) { | 2808 | | - abuffer.append(sep); | 2809 | | - abuffer.append(path); | 2810 | | - abuffer.append(list[i]); | | 2803 | + sb.append(sep); | | 2804 | + sb.append(path); | | 2805 | + sb.append(list[i]); | 2811 | 2806 | } | 2812 | 2807 | } | 2813 | 2808 | } catch (IOException e) { | 2814 | 2809 | e.printStackTrace(); // this would be odd | 2815 | 2810 | } | 2816 | | - //System.out.println("included path is " + abuffer.toString()); | 2817 | | - //packageListFromClassPath(abuffer.toString()); // WHY? | 2818 | | - return abuffer.toString(); | | 2811 | + return sb.toString(); | 2819 | 2812 | } | 2820 | 2813 |
| 2821 | 2814 |
| |
Collapse file Copy file name to clipboardExpand all lines: app/src/processing/app/Sketch.java +10-10Lines changed: 10 additions & 10 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1570,24 +1570,24 @@ static final boolean asciiLetter(char c) { | 1570 | 1570 | */ | 1571 | 1571 | static public String sanitizeName(String origName) { | 1572 | 1572 | char orig[] = origName.toCharArray(); | 1573 | | - StringBuffer buffer = new StringBuffer(); | | 1573 | + StringBuilder sb = new StringBuilder(); | 1574 | 1574 |
| 1575 | 1575 | // Can't lead with a digit (or anything besides a letter), so prefix with | 1576 | 1576 | // "sketch_". In 1.x this prefixed with an underscore, but those get shaved | 1577 | 1577 | // off later, since you can't start a sketch name with underscore anymore. | 1578 | 1578 | if (!asciiLetter(orig[0])) { | 1579 | | - buffer.append("sketch_"); | | 1579 | + sb.append("sketch_"); | 1580 | 1580 | } | 1581 | 1581 | // for (int i = 0; i < orig.length; i++) { | 1582 | 1582 | for (char c : orig) { | 1583 | 1583 | if (asciiLetter(c) || (c >= '0' && c <= '9')) { | 1584 | | - buffer.append(c); | | 1584 | + sb.append(c); | 1585 | 1585 |
| 1586 | 1586 | } else { | 1587 | 1587 | // Tempting to only add if prev char is not underscore, but that | 1588 | 1588 | // might be more confusing if lots of chars are converted and the | 1589 | 1589 | // result is a very short string thats nothing like the original. | 1590 | | - buffer.append('_'); | | 1590 | + sb.append('_'); | 1591 | 1591 | } | 1592 | 1592 | } | 1593 | 1593 | // Let's not be ridiculous about the length of filenames. | @@ -1596,22 +1596,22 @@ static public String sanitizeName(String origName) { | 1596 | 1596 | // Limiting to that for sketches would mean setting the | 1597 | 1597 | // upper-bound on the character limit here to 25 characters | 1598 | 1598 | // (to handle the base name + ".class") | 1599 | | - if (buffer.length() > 63) { | 1600 | | - buffer.setLength(63); | | 1599 | + if (sb.length() > 63) { | | 1600 | + sb.setLength(63); | 1601 | 1601 | } | 1602 | 1602 | // Remove underscores from the beginning, these seem to be a reserved | 1603 | 1603 | // thing on Android, plus it sometimes causes trouble elsewhere. | 1604 | 1604 | int underscore = 0; | 1605 | | - while (underscore < buffer.length() && buffer.charAt(underscore) == '_') { | | 1605 | + while (underscore < sb.length() && sb.charAt(underscore) == '_') { | 1606 | 1606 | underscore++; | 1607 | 1607 | } | 1608 | | - if (underscore == buffer.length()) { | | 1608 | + if (underscore == sb.length()) { | 1609 | 1609 | return "bad_sketch_name_please_fix"; | 1610 | 1610 |
| 1611 | 1611 | } else if (underscore != 0) { | 1612 | | - return buffer.substring(underscore); | | 1612 | + return sb.substring(underscore); | 1613 | 1613 | } | 1614 | | - return buffer.toString(); | | 1614 | + return sb.toString(); | 1615 | 1615 | } | 1616 | 1616 |
| 1617 | 1617 |
| |
Collapse file Copy file name to clipboardExpand all lines: app/src/processing/app/exec/ProcessHelper.java +1-12Lines changed: 1 addition & 12 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -50,17 +50,6 @@ public ProcessHelper(File dir, final String... cmd) { | 50 | 50 |
| 51 | 51 | @Override | 52 | 52 | public String toString() { | 53 | | - /* | 54 | | - final StringBuffer buffer = new StringBuffer(); | 55 | | - for (int i = 0; i < cmd.length; i++) { | 56 | | - if (i != 0) { | 57 | | - buffer.append(' '); | 58 | | - } | 59 | | - buffer.append(cmd[i]); | 60 | | - } | 61 | | - return buffer.toString(); | 62 | | - */ | 63 | | -// return exe + " " + PApplet.join(args, " "); | 64 | 53 | return PApplet.join(cmd, " "); | 65 | 54 | } | 66 | 55 |
| @@ -143,4 +132,4 @@ static public boolean ffs(final String... cmd) { | 143 | 132 | } | 144 | 133 | return false; | 145 | 134 | } | 146 | | -} | | 135 | +} |
Collapse file Copy file name to clipboardExpand all lines: app/src/processing/app/syntax/InputHandler.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1151,10 +1151,10 @@ public void actionPerformed(ActionEvent evt) | 1151 | 1151 |
| 1152 | 1152 | if(textArea.isEditable()) | 1153 | 1153 | { | 1154 | | - StringBuffer buf = new StringBuffer(); | | 1154 | + StringBuilder sb = new StringBuilder(); | 1155 | 1155 | for(int i = 0; i < repeatCount; i++) | 1156 | | - buf.append(str); | 1157 | | - textArea.overwriteSetSelectedText(buf.toString()); | | 1156 | + sb.append(str); | | 1157 | + textArea.overwriteSetSelectedText(sb.toString()); | 1158 | 1158 | } | 1159 | 1159 | else | 1160 | 1160 | { | |
Collapse file Copy file name to clipboardExpand all lines: app/src/processing/app/syntax/JEditTextArea.java +13-13Lines changed: 13 additions & 13 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1397,7 +1397,7 @@ public final String getSelectedText() | 1397 | 1397 | start = tmp; | 1398 | 1398 | } | 1399 | 1399 |
| 1400 | | - StringBuffer buf = new StringBuffer(); | | 1400 | + StringBuilder sb = new StringBuilder(); | 1401 | 1401 | Segment seg = new Segment(); | 1402 | 1402 |
| 1403 | 1403 | for(int i = selectionStartLine; i <= selectionEndLine; i++) | @@ -1411,13 +1411,13 @@ public final String getSelectedText() | 1411 | 1411 | lineLen = Math.min(end - start,lineEnd - lineStart); | 1412 | 1412 |
| 1413 | 1413 | getText(lineStart,lineLen,seg); | 1414 | | - buf.append(seg.array,seg.offset,seg.count); | | 1414 | + sb.append(seg.array,seg.offset,seg.count); | 1415 | 1415 |
| 1416 | 1416 | if(i != selectionEndLine) | 1417 | | - buf.append('\n'); | | 1417 | + sb.append('\n'); | 1418 | 1418 | } | 1419 | 1419 |
| 1420 | | - return buf.toString(); | | 1420 | + return sb.toString(); | 1421 | 1421 | } | 1422 | 1422 | else | 1423 | 1423 | { | @@ -1691,11 +1691,11 @@ public void copy() { | 1691 | 1691 | String selection = getSelectedText(); | 1692 | 1692 |
| 1693 | 1693 | int repeatCount = inputHandler.getRepeatCount(); | 1694 | | - StringBuffer buf = new StringBuffer(); | | 1694 | + StringBuilder sb = new StringBuilder(); | 1695 | 1695 | for(int i = 0; i < repeatCount; i++) | 1696 | | - buf.append(selection); | | 1696 | + sb.append(selection); | 1697 | 1697 |
| 1698 | | - clipboard.setContents(new StringSelection(buf.toString()),null); | | 1698 | + clipboard.setContents(new StringSelection(sb.toString()), null); | 1699 | 1699 | } | 1700 | 1700 | } | 1701 | 1701 |
| @@ -1721,7 +1721,7 @@ public void copy() { | 1721 | 1721 | * specific to any language or version of the PDE. | 1722 | 1722 | */ | 1723 | 1723 | public void copyAsHTML() { | 1724 | | - StringBuffer cf = new StringBuffer("<html><body><pre>\n"); | | 1724 | + StringBuilder cf = new StringBuilder("<html><body><pre>\n"); | 1725 | 1725 |
| 1726 | 1726 | int selStart = getSelectionStart(); | 1727 | 1727 | int selStop = getSelectionStop(); | @@ -1758,7 +1758,7 @@ public void lostOwnership(Clipboard clipboard, Transferable contents) { | 1758 | 1758 | } | 1759 | 1759 |
| 1760 | 1760 |
| 1761 | | - private void emitAsHTML(StringBuffer cf, int line) { | | 1761 | + private void emitAsHTML(StringBuilder cf, int line) { | 1762 | 1762 | Segment segment = new Segment(); | 1763 | 1763 | getLineText(line, segment); | 1764 | 1764 |
| @@ -1839,7 +1839,7 @@ private void emitAsHTML(StringBuffer cf, int line) { | 1839 | 1839 | /** | 1840 | 1840 | * Handle encoding HTML entities for lt, gt, and anything non-ASCII. | 1841 | 1841 | */ | 1842 | | - private void appendAsHTML(StringBuffer buffer, char c) { | | 1842 | + private void appendAsHTML(StringBuilder buffer, char c) { | 1843 | 1843 | if (c == '<') { | 1844 | 1844 | buffer.append("<"); | 1845 | 1845 | } else if (c == '>') { | @@ -1903,11 +1903,11 @@ public void paste() { | 1903 | 1903 | } | 1904 | 1904 |
| 1905 | 1905 | int repeatCount = inputHandler.getRepeatCount(); | 1906 | | - StringBuffer buf = new StringBuffer(); | | 1906 | + StringBuilder sb = new StringBuilder(); | 1907 | 1907 | for (int i = 0; i < repeatCount; i++) { | 1908 | | - buf.append(selection); | | 1908 | + sb.append(selection); | 1909 | 1909 | } | 1910 | | - selection = buf.toString(); | | 1910 | + selection = sb.toString(); | 1911 | 1911 | setSelectedText(selection); | 1912 | 1912 |
| 1913 | 1913 | } catch (Exception e) { | |
Collapse file Copy file name to clipboardExpand all lines: app/src/processing/app/syntax/im/CompositionTextManager.java +1-1Lines changed: 1 addition & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -94,7 +94,7 @@ public void processCompositionText(AttributedCharacterIterator text, int committ | 94 | 94 | CompositionTextPainter compositionPainter = textArea.getPainter().getCompositionTextpainter(); | 95 | 95 | compositionPainter.setComposedTextLayout(getTextLayout(text, committed_count), layoutCaretPosition); | 96 | 96 | int textLength = text.getEndIndex() - text.getBeginIndex() - committed_count; | 97 | | - StringBuffer unCommitedStringBuf = new StringBuffer(textLength); | | 97 | + StringBuilder unCommitedStringBuf = new StringBuilder(textLength); | 98 | 98 | char c; | 99 | 99 | for (c = text.setIndex(committed_count); c != CharacterIterator.DONE | 100 | 100 | && textLength > 0; c = text.next(), --textLength) { | |
Collapse file Copy file name to clipboardExpand all lines: app/src/processing/mode/java/Compiler.java +2-2Lines changed: 2 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -103,8 +103,8 @@ static public boolean compile(JavaBuild build) throws SketchException { | 103 | 103 | // PApplet.println(command); | 104 | 104 |
| 105 | 105 | try { | 106 | | - // Load errors into a local StringBuffer | 107 | | - final StringBuffer errorBuffer = new StringBuffer(); | | 106 | + // Load errors into a local StringBuilder | | 107 | + final StringBuilder errorBuffer = new StringBuilder(); | 108 | 108 |
| 109 | 109 | // Create single method dummy writer class to slurp errors from ecj | 110 | 110 | Writer internalWriter = new Writer() { | |
Collapse file Copy file name to clipboardExpand all lines: app/src/processing/mode/java/JavaBuild.java +3-3Lines changed: 3 additions & 3 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -234,7 +234,7 @@ public String preprocess(File srcFolder, | 234 | 234 | // 1. concatenate all .pde files to the 'main' pde | 235 | 235 | // store line number for starting point of each code bit | 236 | 236 |
| 237 | | - StringBuffer bigCode = new StringBuffer(); | | 237 | + StringBuilder bigCode = new StringBuilder(); | 238 | 238 | int bigCount = 0; | 239 | 239 | for (SketchCode sc : sketch.getCode()) { | 240 | 240 | if (sc.isExtension("pde")) { | @@ -1417,7 +1417,7 @@ protected boolean exportApplication(File destFolder, | 1417 | 1417 |
| 1418 | 1418 | String jarList[] = new String[jarListVector.size()]; | 1419 | 1419 | jarListVector.copyInto(jarList); | 1420 | | - StringBuffer exportClassPath = new StringBuffer(); | | 1420 | + StringBuilder exportClassPath = new StringBuilder(); | 1421 | 1421 |
| 1422 | 1422 | if (exportPlatform == PConstants.MACOSX) { | 1423 | 1423 | for (int i = 0; i < jarList.length; i++) { | @@ -1474,7 +1474,7 @@ protected boolean exportApplication(File destFolder, | 1474 | 1474 | String lines[] = PApplet.loadStrings(plistTemplate); | 1475 | 1475 | for (int i = 0; i < lines.length; i++) { | 1476 | 1476 | if (lines[i].indexOf("@@") != -1) { | 1477 | | - StringBuffer sb = new StringBuffer(lines[i]); | | 1477 | + StringBuilder sb = new StringBuilder(lines[i]); | 1478 | 1478 | int index = 0; | 1479 | 1479 | while ((index = sb.indexOf("@@jvm_runtime@@")) != -1) { | 1480 | 1480 | sb.replace(index, index + "@@jvm_runtime@@".length(), | |
Collapse file Copy file name to clipboardExpand all lines: app/src/processing/mode/java/JavaEditor.java +7-7Lines changed: 7 additions & 7 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -791,15 +791,15 @@ public void handleImportLibrary(String jarPath) { | 791 | 791 | // statement is already in there, but if the user has the import | 792 | 792 | // commented out, then this will be a problem. | 793 | 793 | String[] list = Base.packageListFromClassPath(jarPath); | 794 | | - StringBuffer buffer = new StringBuffer(); | | 794 | + StringBuilder sb = new StringBuilder(); | 795 | 795 | for (int i = 0; i < list.length; i++) { | 796 | | - buffer.append("import "); | 797 | | - buffer.append(list[i]); | 798 | | - buffer.append(".*;\n"); | | 796 | + sb.append("import "); | | 797 | + sb.append(list[i]); | | 798 | + sb.append(".*;\n"); | 799 | 799 | } | 800 | | - buffer.append('\n'); | 801 | | - buffer.append(getText()); | 802 | | - setText(buffer.toString()); | | 800 | + sb.append('\n'); | | 801 | + sb.append(getText()); | | 802 | + setText(sb.toString()); | 803 | 803 | setSelection(0, 0); // scroll to start | 804 | 804 | sketch.setModified(true); | 805 | 805 | } | |
|