Skip to content

Commit

Permalink
Optimization for AbstractLazyLoadRunMap.loadNumberOnDisk (#8494)
Browse files Browse the repository at this point in the history
  • Loading branch information
jglick authored Sep 20, 2023
1 parent c8874d0 commit e996d0c
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
import java.util.function.IntConsumer;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
import jenkins.util.MemoryReductionUtil;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;
Expand Down Expand Up @@ -332,6 +333,8 @@ public synchronized void purgeCache() {
loadNumberOnDisk();
}

private static final Pattern BUILD_NUMBER = Pattern.compile("[0-9]+");

private void loadNumberOnDisk() {
String[] kids = dir.list();
if (kids == null) {
Expand All @@ -340,10 +343,14 @@ private void loadNumberOnDisk() {
}
SortedIntList list = new SortedIntList(kids.length / 2);
for (String s : kids) {
if (!BUILD_NUMBER.matcher(s).matches()) {
// not a build directory
continue;
}
try {
list.add(Integer.parseInt(s));
} catch (NumberFormatException e) {
// this isn't a build dir
// matched BUILD_NUMBER but not an int?
}
}
list.sort();
Expand Down

0 comments on commit e996d0c

Please sign in to comment.