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

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

    XMLWordPrintable

Details

    • Icon: Improvement Improvement
    • Resolution: Fixed
    • Icon: Minor Minor
    • 1.3.0
    • 1.2.3
    • logback-core
    • 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

            ceki Ceki Gülcü
            ankinson Andy Wilkinson
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: