Skip to content

Commit

Permalink
perf(artifacts): compile appliationsRegex once instead of on each use
Browse files Browse the repository at this point in the history
  • Loading branch information
dbyron-sf committed Mar 3, 2024
1 parent b18f1b1 commit 3330260
Showing 1 changed file with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class S3ArtifactStoreStorer implements ArtifactStoreStorer {
private final S3Client s3Client;
private final String bucket;
private final ArtifactStoreURIBuilder uriBuilder;
private final String applicationsRegex;
private final Pattern applicationsPattern;

public S3ArtifactStoreStorer(
S3Client s3Client,
Expand All @@ -58,7 +58,8 @@ public S3ArtifactStoreStorer(
this.s3Client = s3Client;
this.bucket = bucket;
this.uriBuilder = uriBuilder;
this.applicationsRegex = applicationsRegex;
this.applicationsPattern =
(applicationsRegex != null) ? Pattern.compile(applicationsRegex) : null;
}

/**
Expand All @@ -76,7 +77,7 @@ public Artifact store(Artifact artifact) {
return artifact;
}

if (applicationsRegex != null && !Pattern.matches(applicationsRegex, application)) {
if (applicationsPattern != null && !applicationsPattern.matcher(application).matches()) {
return artifact;
}

Expand Down

0 comments on commit 3330260

Please sign in to comment.