Skip to content

Commit

Permalink
Fix poor performance of listunrunchangesets (#4798)
Browse files Browse the repository at this point in the history
* Do not call normalizePath inside the loop for the same variable + just call it if everything else is fine.
  • Loading branch information
filipelautert committed Sep 1, 2023
1 parent 7e709fe commit c0a837a
Showing 1 changed file with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,15 @@ public ChangeSet getChangeSet(String path, String author, String id) {

public List<ChangeSet> getChangeSets(String path, String author, String id) {
final ArrayList<ChangeSet> changeSetsToReturn = new ArrayList<>();
for (ChangeSet changeSet : this.changeSets) {
final String normalizedPath = normalizePath(changeSet.getFilePath());
if (normalizedPath != null &&
normalizedPath.equalsIgnoreCase(normalizePath(path)) &&
changeSet.getAuthor().equalsIgnoreCase(author) &&
changeSet.getId().equalsIgnoreCase(id) &&
isDbmsMatch(changeSet.getDbmsSet())) {
changeSetsToReturn.add(changeSet);
final String normalizedPath = normalizePath(path);
if (normalizedPath != null) {
for (ChangeSet changeSet : this.changeSets) {
if (changeSet.getAuthor().equalsIgnoreCase(author) && changeSet.getId().equalsIgnoreCase(id) && isDbmsMatch(changeSet.getDbmsSet())) {
final String changesetNormalizedPath = normalizePath(changeSet.getFilePath());
if (changesetNormalizedPath != null && changesetNormalizedPath.equalsIgnoreCase(normalizedPath)) {
changeSetsToReturn.add(changeSet);
}
}
}
}
return changeSetsToReturn;
Expand Down Expand Up @@ -353,7 +354,7 @@ public void validate(Database database, Contexts contexts, LabelExpression label
}
}

public ChangeSet getChangeSet(RanChangeSet ranChangeSet) {
public ChangeSet getChangeSet(RanChangeSet ranChangeSet) {
final ChangeSet changeSet = getChangeSet(ranChangeSet.getChangeLog(), ranChangeSet.getAuthor(), ranChangeSet.getId());
if (changeSet != null) {
changeSet.setStoredFilePath(ranChangeSet.getStoredChangeLog());
Expand Down

0 comments on commit c0a837a

Please sign in to comment.