donnerpeter commented on a change in pull request #2300:
URL: https://github.com/apache/lucene-solr/pull/2300#discussion_r570086999



##########
File path: 
lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/CheckCompoundPattern.java
##########
@@ -38,36 +38,33 @@
     }
 
     int flagSep = parts[1].indexOf("/");
-    endChars = (flagSep < 0 ? parts[1] : parts[1].substring(0, 
flagSep)).toCharArray();
+    endChars = flagSep < 0 ? parts[1] : parts[1].substring(0, flagSep);
     endFlags = flagSep < 0 ? new char[0] : 
strategy.parseFlags(parts[1].substring(flagSep + 1));
 
     flagSep = parts[2].indexOf("/");
-    beginChars = (flagSep < 0 ? parts[2] : parts[2].substring(0, 
flagSep)).toCharArray();
+    beginChars = flagSep < 0 ? parts[2] : parts[2].substring(0, flagSep);
     beginFlags = flagSep < 0 ? new char[0] : 
strategy.parseFlags(parts[2].substring(flagSep + 1));
 
-    replacement = parts.length == 3 ? null : parts[3].toCharArray();
+    replacement = parts.length == 3 ? null : parts[3];
   }
 
   @Override
   public String toString() {
-    return new String(endChars)
-        + " "
-        + new String(beginChars)
-        + (replacement == null ? "" : " -> " + new String(replacement));
+    return endChars + " " + beginChars + (replacement == null ? "" : " -> " + 
replacement);
   }
 
   boolean prohibitsCompounding(
       CharsRef word, int breakPos, CharsRef stemBefore, CharsRef stemAfter) {
     if (isNonAffixedPattern(endChars)) {
-      if (!charsMatch(word, breakPos - stemBefore.length, stemBefore.chars)) {

Review comment:
       There was a bug here: `stemBefore.chars` was checked fully, disregarding 
`offset/length`. Now we pass in `CharSequence` to avoid that

##########
File path: 
lucene/analysis/common/src/java/org/apache/lucene/analysis/hunspell/CheckCompoundPattern.java
##########
@@ -38,36 +38,33 @@
     }
 
     int flagSep = parts[1].indexOf("/");
-    endChars = (flagSep < 0 ? parts[1] : parts[1].substring(0, 
flagSep)).toCharArray();
+    endChars = flagSep < 0 ? parts[1] : parts[1].substring(0, flagSep);
     endFlags = flagSep < 0 ? new char[0] : 
strategy.parseFlags(parts[1].substring(flagSep + 1));
 
     flagSep = parts[2].indexOf("/");
-    beginChars = (flagSep < 0 ? parts[2] : parts[2].substring(0, 
flagSep)).toCharArray();
+    beginChars = flagSep < 0 ? parts[2] : parts[2].substring(0, flagSep);
     beginFlags = flagSep < 0 ? new char[0] : 
strategy.parseFlags(parts[2].substring(flagSep + 1));
 
-    replacement = parts.length == 3 ? null : parts[3].toCharArray();
+    replacement = parts.length == 3 ? null : parts[3];
   }
 
   @Override
   public String toString() {
-    return new String(endChars)
-        + " "
-        + new String(beginChars)
-        + (replacement == null ? "" : " -> " + new String(replacement));
+    return endChars + " " + beginChars + (replacement == null ? "" : " -> " + 
replacement);
   }
 
   boolean prohibitsCompounding(
       CharsRef word, int breakPos, CharsRef stemBefore, CharsRef stemAfter) {
     if (isNonAffixedPattern(endChars)) {
-      if (!charsMatch(word, breakPos - stemBefore.length, stemBefore.chars)) {

Review comment:
       There was a bug here: `stemBefore.chars` was checked fully, disregarding 
`offset/length`. Now we pass in `CharSequence` to avoid looking at characters 
outside the range.




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