Uploaded image for project: 'Cassandra'
  1. Cassandra
  2. CASSANDRA-15033

Refactor to singleQuote reuse java.util.regex.Pattern instead of String.replaceAll for TableCQLHelper.java

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Low
    • Resolution: Fixed
    • 4.0-alpha1, 4.0
    • CQL/Interpreter
    • None

    Description

      singleQuote uses `String.replaceAll ()` a lot in loop.

      and 'String.replaceAll()' compiles the regular expression each time it is called.

       

      public String replaceAll(String regex, String replacement) {
          return Pattern.compile(regex).matcher(this).replaceAll(replacement);
       }

       

      It is suggested in javadoc (https://docs.oracle.com/javase/8/docs/api/java/util/regex/Pattern.html#matches(java.lang.String,%20java.lang.CharSequence)) that it is efficient to reuse the pattern.

      Attachments

        1. patch-15033.patch
          1 kB
          DaeMyung Kang

        Activity

          People

            charsyam DaeMyung Kang
            charsyam DaeMyung Kang
            DaeMyung Kang
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: