karaf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gno...@apache.org
Subject [karaf] 04/05: Use a StringBuilder instead of string concatenations
Date Thu, 23 Nov 2017 08:00:26 GMT
This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/karaf.git

commit b46deeec1ab6f5cd3016dd96cec1372c5e3f31af
Author: Guillaume Nodet <gnodet@gmail.com>
AuthorDate: Thu Nov 23 08:56:18 2017 +0100

    Use a StringBuilder instead of string concatenations
---
 .../org/apache/karaf/webconsole/gogo/Terminal.java | 104 ++++++++++-----------
 1 file changed, 52 insertions(+), 52 deletions(-)

diff --git a/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java
b/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java
index 70a860a..ab9b7b3 100644
--- a/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java
+++ b/webconsole/gogo/src/main/java/org/apache/karaf/webconsole/gogo/Terminal.java
@@ -1557,152 +1557,152 @@ public class Terminal {
     }
 
     public synchronized String pipe(String d) {
-        String o = "";
+        StringBuilder o = new StringBuilder();
         for (char c : d.toCharArray()) {
             if (vt100_keyfilter_escape) {
                 vt100_keyfilter_escape = false;
                 if (vt100_mode_cursorkey) {
                     switch (c) {
                         case '~':
-                            o += "~";
+                            o.append("~");
                             break;
                         case 'A':
-                            o += "\u001bOA";
+                            o.append("\u001bOA");
                             break;
                         case 'B':
-                            o += "\u001bOB";
+                            o.append("\u001bOB");
                             break;
                         case 'C':
-                            o += "\u001bOC";
+                            o.append("\u001bOC");
                             break;
                         case 'D':
-                            o += "\u001bOD";
+                            o.append("\u001bOD");
                             break;
                         case 'F':
-                            o += "\u001bOF";
+                            o.append("\u001bOF");
                             break;
                         case 'H':
-                            o += "\u001bOH";
+                            o.append("\u001bOH");
                             break;
                         case '1':
-                            o += "\u001b[5~";
+                            o.append("\u001b[5~");
                             break;
                         case '2':
-                            o += "\u001b[6~";
+                            o.append("\u001b[6~");
                             break;
                         case '3':
-                            o += "\u001b[2~";
+                            o.append("\u001b[2~");
                             break;
                         case '4':
-                            o += "\u001b[3~";
+                            o.append("\u001b[3~");
                             break;
                         case 'a':
-                            o += "\u001bOP";
+                            o.append("\u001bOP");
                             break;
                         case 'b':
-                            o += "\u001bOQ";
+                            o.append("\u001bOQ");
                             break;
                         case 'c':
-                            o += "\u001bOR";
+                            o.append("\u001bOR");
                             break;
                         case 'd':
-                            o += "\u001bOS";
+                            o.append("\u001bOS");
                             break;
                         case 'e':
-                            o += "\u001b[15~";
+                            o.append("\u001b[15~");
                             break;
                         case 'f':
-                            o += "\u001b[17~";
+                            o.append("\u001b[17~");
                             break;
                         case 'g':
-                            o += "\u001b[18~";
+                            o.append("\u001b[18~");
                             break;
                         case 'h':
-                            o += "\u001b[19~";
+                            o.append("\u001b[19~");
                             break;
                         case 'i':
-                            o += "\u001b[20~";
+                            o.append("\u001b[20~");
                             break;
                         case 'j':
-                            o += "\u001b[21~";
+                            o.append("\u001b[21~");
                             break;
                         case 'k':
-                            o += "\u001b[23~";
+                            o.append("\u001b[23~");
                             break;
                         case 'l':
-                            o += "\u001b[24~";
+                            o.append("\u001b[24~");
                             break;
                     }
                 } else {
                     switch (c) {
                         case '~':
-                            o += "~";
+                            o.append("~");
                             break;
                         case 'A':
-                            o += "\u001b[A";
+                            o.append("\u001b[A");
                             break;
                         case 'B':
-                            o += "\u001b[B";
+                            o.append("\u001b[B");
                             break;
                         case 'C':
-                            o += "\u001b[C";
+                            o.append("\u001b[C");
                             break;
                         case 'D':
-                            o += "\u001b[D";
+                            o.append("\u001b[D");
                             break;
                         case 'F':
-                            o += "\u001b[F";
+                            o.append("\u001b[F");
                             break;
                         case 'H':
-                            o += "\u001b[H";
+                            o.append("\u001b[H");
                             break;
                         case '1':
-                            o += "\u001b[5~";
+                            o.append("\u001b[5~");
                             break;
                         case '2':
-                            o += "\u001b[6~";
+                            o.append("\u001b[6~");
                             break;
                         case '3':
-                            o += "\u001b[2~";
+                            o.append("\u001b[2~");
                             break;
                         case '4':
-                            o += "\u001b[3~";
+                            o.append("\u001b[3~");
                             break;
                         case 'a':
-                            o += "\u001bOP";
+                            o.append("\u001bOP");
                             break;
                         case 'b':
-                            o += "\u001bOQ";
+                            o.append("\u001bOQ");
                             break;
                         case 'c':
-                            o += "\u001bOR";
+                            o.append("\u001bOR");
                             break;
                         case 'd':
-                            o += "\u001bOS";
+                            o.append("\u001bOS");
                             break;
                         case 'e':
-                            o += "\u001b[15~";
+                            o.append("\u001b[15~");
                             break;
                         case 'f':
-                            o += "\u001b[17~";
+                            o.append("\u001b[17~");
                             break;
                         case 'g':
-                            o += "\u001b[18~";
+                            o.append("\u001b[18~");
                             break;
                         case 'h':
-                            o += "\u001b[19~";
+                            o.append("\u001b[19~");
                             break;
                         case 'i':
-                            o += "\u001b[20~";
+                            o.append("\u001b[20~");
                             break;
                         case 'j':
-                            o += "\u001b[21~";
+                            o.append("\u001b[21~");
                             break;
                         case 'k':
-                            o += "\u001b[23~";
+                            o.append("\u001b[23~");
                             break;
                         case 'l':
-                            o += "\u001b[24~";
+                            o.append("\u001b[24~");
                             break;
                     }
                 }
@@ -1710,18 +1710,18 @@ public class Terminal {
                 vt100_keyfilter_escape = true;
             } else if (c == '\u007f') {
                 if (vt100_mode_backspace) {
-                    o += '\u0008';
+                    o.append('\u0008');
                 } else {
-                    o += '\u007f';
+                    o.append('\u007f');
                 }
             } else {
-                o += c;
+                o.append(c);
                 if (vt100_mode_lfnewline && c == '\r') {
-                    o += '\n';
+                    o.append('\n');
                 }
             }
         }
-        return o;
+        return o.toString();
     }
 
     public synchronized boolean write(String d) {

-- 
To stop receiving notification emails like this one, please contact
"commits@karaf.apache.org" <commits@karaf.apache.org>.

Mime
View raw message