elek commented on a change in pull request #2331:
URL: https://github.com/apache/ozone/pull/2331#discussion_r652453883



##########
File path: 
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/client/ECReplicationConfig.java
##########
@@ -36,6 +43,29 @@ public ECReplicationConfig(int data, int parity) {
     this.parity = parity;
   }
 
+  public ECReplicationConfig(String string) {
+    final Pattern pattern = Pattern.compile("(\\d+)-(\\d+)");
+    final Matcher matcher = pattern.matcher(string);

Review comment:
       Good point. Let me move it to a static final constant.
   
   Answering the question is slightly harder. Compilation time I couldn't see 
any optimization:
   
   
   ```
   javap -v org.apache.hadoop.hdds.client.ECReplicationConfig
   
   ...
   
     public org.apache.hadoop.hdds.client.ECReplicationConfig(java.lang.String);
       descriptor: (Ljava/lang/String;)V
       flags: ACC_PUBLIC
       Code:
         stack=3, locals=4, args_size=2
            0: aload_0
            1: invokespecial #1                  // Method 
java/lang/Object."<init>":()V
            4: ldc           #4                  // String (\d+)-(\d+)
            6: invokestatic  #5                  // Method 
java/util/regex/Pattern.compile:(Ljava/lang/String;)Ljava/util/regex/Pattern;
            9: astore_2
   ```
   
   The call is really compiled as is to the method.
   
   Runtime optimization it's another question, but I don't think that it's 
possible easily as hostpost JVM would require understanding about the 
idempotency of `Pattern.compile` (second call on `Pattern.compile` returns with 
a value which is equivalent to the first one.)
   
   --> looks better to move the compile to a static field...
   




-- 
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.

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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to