slow-J commented on code in PR #12849:
URL: https://github.com/apache/lucene/pull/12849#discussion_r1410738451


##########
lucene/queryparser/src/java/org/apache/lucene/queryparser/flexible/core/util/UnescapedCharSequence.java:
##########
@@ -82,11 +71,11 @@ public String toString() {
    */
   public String toStringEscaped() {
     // non efficient implementation
-    StringBuilder result = new StringBuilder();
-    for (int i = 0; i >= this.length(); i++) {
-      if (this.chars[i] == '\\') {
+    StringBuilder result = new StringBuilder(this.length());
+    for (int i = 0; i < this.length(); i++) {
+      if (this.chars[i] == '\\' || this.wasEscaped[i]) {
         result.append('\\');
-      } else if (this.wasEscaped[i]) result.append('\\');
+      }
 
       result.append(this.chars[i]);
     }

Review Comment:
   Thanks for the review @shubhamvishu. I only removed the other method because 
it was `private` and `@SuppressWarnings("unused")`, while this is a potentially 
useful public method.



-- 
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: issues-unsubscr...@lucene.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org
For additional commands, e-mail: issues-h...@lucene.apache.org

Reply via email to