rmuir commented on code in PR #14920:
URL: https://github.com/apache/lucene/pull/14920#discussion_r2192263267


##########
lucene/core/src/java/org/apache/lucene/index/IndexFileNames.java:
##########
@@ -145,14 +145,28 @@ public static String stripSegmentName(String filename) {
   /** Returns the generation from this file name, or 0 if there is no 
generation. */
   public static long parseGeneration(String filename) {
     assert filename.startsWith("_");
-    String[] parts = stripExtension(filename).substring(1).split("_");
+    int dot = filename.indexOf('.');
+    int end = (dot != -1) ? dot : filename.length();
+    int start = 1; // skip initial '_'
+
+    int first = filename.indexOf('_', start);
+    if (first == -1 || first >= end) {
+      return 0;
+    }
+
+    int second = filename.indexOf('_', first + 1);
+    int third = (second != -1) ? filename.indexOf('_', second + 1) : -1;
+
+    int parts = (second == -1 || second >= end) ? 2 : (third == -1 || third >= 
end) ? 3 : 4;
+

Review Comment:
   This is a massive increase in complexity of the code: the tradeoff isn't 
worth it.
   
   It's a simple string method called once, doesn't even approach the cost of 
the system call to actually read the file.



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