Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-1409

Compile and reuse a Pattern in FileFilterUtil.computeCurrentPeriodsHighestCounterValue(String)

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 1.2.3
    • Fix Version/s: 1.3.0-alpha6
    • Component/s: logback-core
    • Labels:
      None

      Description

      FileFilterUtil.filesInFolderMatchingStemRegex(String) currently calls String.matches(stemRegex) once for each file or directory in the folder. The is inefficient and noticeably so for folders with large numbers of files as it causes the same Pattern to be compiled once for each file or directory in the folder. The repeat compilation could be avoided by performing it once outside of the filtering callback:

      Pattern pattern = Pattern.compile(stemRegex);
      return file.listFiles(new FilenameFilter() {
      	@Override
      	public boolean accept(File dir, String name) {
      		return pattern.matcher(name).matches();
      	}
      });
      

        Attachments

          Activity

            People

            Assignee:
            logback-dev Logback dev list
            Reporter:
            ankinson Andy Wilkinson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: