Skip to content

Commit

Permalink
Use replace instead of replaceall
Browse files Browse the repository at this point in the history
replaceall expects a regex as first argument and uses Pattern.compile(regex) (performance overhead)

Signed-off-by: Laurent Klock <[email protected]>
  • Loading branch information
klockla committed Nov 19, 2024
1 parent 5caede6 commit 1f3c895
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public int hashCode() {

@Override
public String toString() {
return this.getCrawlid().replaceAll("_", "%5F")
+ "_"
+ this.getQueue().replaceAll("_", "%5F");
return this.getCrawlid().replace("_", "%5F") + "_" + this.getQueue().replace("_", "%5F");
}

public int compareTo(QueueWithinCrawl target) {
Expand All @@ -70,11 +68,11 @@ public int compareTo(QueueWithinCrawl target) {

public static final QueueWithinCrawl parseAndDeNormalise(final String currentKey) {
final int pos = currentKey.indexOf('_');
final String crawlID = currentKey.substring(0, pos).replaceAll("%5F", "_");
final String crawlID = currentKey.substring(0, pos).replace("%5F", "_");
int pos2 = currentKey.indexOf('_', pos + 1);
// no separator? just normalise whatever is left
if (pos2 == -1) pos2 = currentKey.length();
final String queueID = currentKey.substring(pos + 1, pos2).replaceAll("%5F", "_");
final String queueID = currentKey.substring(pos + 1, pos2).replace("%5F", "_");
return QueueWithinCrawl.get(queueID, crawlID);
}
}

0 comments on commit 1f3c895

Please sign in to comment.