mxsm commented on code in PR #5508:
URL: https://github.com/apache/rocketmq/pull/5508#discussion_r1019784348


##########
common/src/main/java/org/apache/rocketmq/common/attribute/AttributeParser.java:
##########
@@ -16,38 +16,44 @@
  */
 package org.apache.rocketmq.common.attribute;
 
-import com.google.common.base.Joiner;
 import com.google.common.base.Strings;
-
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
 public class AttributeParser {
+
+    public static final String COMMA = ",";
+
+    public static final String EQUAL_SIGN = "=";
+
+    public static final String PLUS_SIGN = "+";
+
+    private static final String MINUS_SIGN = "-";

Review Comment:
   @caigy  
   > Although those variables should be constant, are there any test results to 
show the exact effect in improving the speed of parsing?
   
   
![image](https://user-images.githubusercontent.com/15797831/201060404-fc40e41d-bb5c-4c4b-a88a-b800bfbd9d8f.png)
   split two times
   
   ```java
   @BenchmarkMode(Mode.Throughput)
   @Warmup(iterations = 3, time = 1)
   @Measurement(iterations = 5, time = 5)
   @Threads(1)
   @Fork(1)
   @State(value = Scope.Benchmark)
   @OutputTimeUnit(TimeUnit.SECONDS)
   public class SplitBenchmark {
   
       private String bbb = "1111,2222";
   
       @Benchmark
       public void splitTwo() {
           String s = bbb.split(",")[0];
           String s1 = bbb.split(",")[1];
       }
   
       @Benchmark
       public void splitOne() {
           String[] split = bbb.split(",");
           String s = split[0];
           String s1 = split[1];
       }
   
       public static void main(String[] args) throws RunnerException {
           Options opt = new OptionsBuilder()
               .include(SplitBenchmark.class.getSimpleName())
               .result("result.json")
               .resultFormat(ResultFormatType.JSON).build();
           new Runner(opt).run();
       }
   }
   ```
   benchmark result:
   
![image](https://user-images.githubusercontent.com/15797831/201061272-d54dd683-3f96-4c29-b64a-defaf37dfa3a.png)
   
    those variables should be constant is polish code



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to