Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 61f4d8d

Browse files
authored
Merge pull request #278 from max-schaefer/fix-upgrade-performance
Improve performance of upgrade script
2 parents 90bab34 + 6d35c60 commit 61f4d8d

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

upgrades/ee5c327face2866a7b3b12dcce5c291be52ebf52/upgrade_comment_groups.ql

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,16 @@ Location getLocation(CommentGroup cg) {
3333
not exists(cg.getLocation()) and result = cg.getComment(0).getLocation()
3434
}
3535

36-
from CommentGroup cg, File f, int idx
36+
pragma[noinline]
37+
predicate hasLocation(CommentGroup cg, File f, int startLine) {
38+
exists(Location loc | loc = getLocation(cg) |
39+
f = loc.getFile() and
40+
startLine = loc.getStartLine()
41+
)
42+
}
43+
44+
from CommentGroup cg, File file, int idx
3745
where
38-
f = getLocation(cg).getFile() and
39-
rank[idx + 1](CommentGroup rankedcg |
40-
getLocation(rankedcg).getFile() = f
41-
|
42-
rankedcg order by getLocation(rankedcg).getStartLine()
43-
) = cg
44-
select cg, f, idx
46+
hasLocation(cg, file, _) and
47+
cg = rank[idx + 1](CommentGroup cg2, int line | hasLocation(cg2, file, line) | cg2 order by line)
48+
select cg, file, idx

0 commit comments

Comments
 (0)