This is an automated email from the ASF dual-hosted git repository.

btellier pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/james-mime4j.git


The following commit(s) were added to refs/heads/master by this push:
     new a756b72  MIME4J-305 ContentUtil::decode can avoid using StringBuilder 
(#51)
a756b72 is described below

commit a756b7251e03559c7d6b21293fc607f948c52cce
Author: Benoit TELLIER <btell...@linagora.com>
AuthorDate: Sat Sep 4 15:42:47 2021 +0700

    MIME4J-305 ContentUtil::decode can avoid using StringBuilder (#51)
    
    StringBuilder is an expensive construct, we spend most of our time, for 
each character, ensuring the capacity of the string builder.
    
    Size being known, the operation simple, we can directly operate on top of a 
char array.
    
    Gains: 78%
---
 core/src/main/java/org/apache/james/mime4j/util/ContentUtil.java | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/core/src/main/java/org/apache/james/mime4j/util/ContentUtil.java 
b/core/src/main/java/org/apache/james/mime4j/util/ContentUtil.java
index 9d7ee45..14a636b 100644
--- a/core/src/main/java/org/apache/james/mime4j/util/ContentUtil.java
+++ b/core/src/main/java/org/apache/james/mime4j/util/ContentUtil.java
@@ -176,11 +176,11 @@ public class ContentUtil {
         if (byteSequence == null) {
             return null;
         }
-        StringBuilder buf = new StringBuilder(length);
+        char[] underlying = new char[length];
         for (int i = offset; i < offset + length; i++) {
-            buf.append((char) (byteSequence.byteAt(i) & 0xff));
+            underlying[i - offset] = (char) (byteSequence.byteAt(i) & 0xff);
         }
-        return buf.toString();
+        return new String(underlying);
     }
 
     /**

---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscr...@james.apache.org
For additional commands, e-mail: server-dev-h...@james.apache.org

Reply via email to