You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by li...@apache.org on 2023/02/10 08:37:40 UTC

[tomcat] branch 8.5.x updated: Improve: Reuse the instance of StringBuilder to avoid duplicate object creation (#588)

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

lihan pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git


The following commit(s) were added to refs/heads/8.5.x by this push:
     new 9a56b27279 Improve: Reuse the instance of StringBuilder to avoid duplicate object creation (#588)
9a56b27279 is described below

commit 9a56b27279c767fcc2cd4269f078980efdf04f33
Author: Andrei Briukhov <an...@gmail.com>
AuthorDate: Fri Feb 10 11:34:59 2023 +0300

    Improve: Reuse the instance of StringBuilder to avoid duplicate object creation (#588)
---
 java/org/apache/catalina/valves/ExtendedAccessLogValve.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
index 26d5eee01c..39474e160e 100644
--- a/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
+++ b/java/org/apache/catalina/valves/ExtendedAccessLogValve.java
@@ -442,22 +442,22 @@ public class ExtendedAccessLogValve extends AccessLogValve {
                 switch (c) {
                 case ' ':
                     result = buf.toString();
-                    buf = new StringBuilder();
+                    buf.setLength(0);
                     buf.append((char) c);
                     return result;
                 case '-':
                     result = buf.toString();
-                    buf = new StringBuilder();
+                    buf.setLength(0);
                     subToken = true;
                     return result;
                 case '(':
                     result = buf.toString();
-                    buf = new StringBuilder();
+                    buf.setLength(0);
                     parameter = true;
                     return result;
                 case ')':
                     result = buf.toString();
-                    buf = new StringBuilder();
+                    buf.setLength(0);
                     break;
                 default:
                     buf.append((char) c);


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org