Skip to content

Commit

Permalink
Merge pull request #581 from schlosna/ds/file-filter-regex
Browse files Browse the repository at this point in the history
[LOGBACK-1409] FileFilterUtil.filesInFolderMatchingStemRegex resuses compiled pattern
  • Loading branch information
ceki committed Aug 22, 2022
2 parents 475281b + ac823db commit cbb1e3d
Showing 1 changed file with 3 additions and 5 deletions.
Expand Up @@ -79,11 +79,9 @@ public static File[] filesInFolderMatchingStemRegex(File file, final String stem
if (!file.exists() || !file.isDirectory()) {
return new File[0];
}
return file.listFiles(new FilenameFilter() {
public boolean accept(File dir, String name) {
return name.matches(stemRegex);
}
});

Pattern regex = Pattern.compile(stemRegex);
return file.listFiles((dir, name) -> regex.matcher(name).matches());
}

static public int findHighestCounter(File[] matchingFileArray, final String stemRegex) {
Expand Down

0 comments on commit cbb1e3d

Please sign in to comment.