nastra commented on code in PR #12301:
URL: https://github.com/apache/iceberg/pull/12301#discussion_r1959863413


##########
api/src/main/java/org/apache/iceberg/FileFormat.java:
##########
@@ -60,9 +60,10 @@ public String addExtension(String filename) {
   public static FileFormat fromFileName(CharSequence filename) {
     for (FileFormat format : VALUES) {
       int extStart = filename.length() - format.ext.length();
-      if (Comparators.charSequences()
-              .compare(format.ext, filename.subSequence(extStart, 
filename.length()))
-          == 0) {
+      if (extStart > 0

Review Comment:
   actually I would consider changing this part to 
   ```
   public static FileFormat fromFileName(CharSequence filename) {
       for (FileFormat format : VALUES) {
         if (null != filename && filename.toString().endsWith(format.ext)) {
           return format;
         }
       }
   
       return null;
     }
   ```
   then we wouldn't need to deal with negative indexes and such and all places 
that call this method already pass an actual `String`, so calling `toString()` 
is cheap



-- 
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...@iceberg.apache.org

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


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

Reply via email to