Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization for AbstractLazyLoadRunMap.loadNumberOnDisk #8494

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading