Skip to content

Commit

Permalink
Avoid expensive operations when comparing commit command work items
Browse files Browse the repository at this point in the history
Reviewed-by: ehelin
  • Loading branch information
rwestberg committed Feb 23, 2021
1 parent a814a3d commit 7e9643c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
Expand Up @@ -87,7 +87,7 @@ public boolean concurrentWith(WorkItem other) {
if (!bot.repo().webUrl().equals(otherItem.bot.repo().webUrl())) {
return true;
}
if (!commitComment.commit().equals(otherItem.commitComment.commit())) {
if (!commitComment.id().equals(otherItem.commitComment.id())) {
return true;
}
return false;
Expand Down
Expand Up @@ -25,7 +25,6 @@
import org.openjdk.skara.bot.*;
import org.openjdk.skara.census.Contributor;
import org.openjdk.skara.forge.*;
import org.openjdk.skara.host.HostUser;
import org.openjdk.skara.issuetracker.*;
import org.openjdk.skara.json.JSONValue;

Expand All @@ -34,8 +33,7 @@
import java.time.*;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Logger;
import java.util.logging.Level;
import java.util.logging.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -192,15 +190,10 @@ public List<WorkItem> getPeriodicItems() {
prs = remoteRepo.pullRequests(ZonedDateTime.now().minus(Duration.ofDays(1)));
}

List<CommitComment> commitComments = List.of();
try {
commitComments = remoteRepo.recentCommitComments()
var commitComments = remoteRepo.recentCommitComments()
.stream()
.filter(cc -> !processedCommitComments.contains(cc.id()))
.filter(cc -> !processedCommitComments.containsKey(cc.id()))
.collect(Collectors.toList());
} catch (Throwable e) {
log.log(Level.SEVERE, "Could not fetch commit comments for " + remoteRepo.name(), e);
}

return getWorkItems(prs, commitComments);
}
Expand Down

1 comment on commit 7e9643c

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.