Skip to content

Commit a18a4fb

Browse files
committed
Avoid magic in TSynthLocation definition
This improves performance, because in this case magic is not beneficial.
1 parent 5e4a5c1 commit a18a4fb

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

go/ql/lib/semmle/go/internal/Locations.qll

+11-4
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,19 @@ newtype TLocation =
1111
TSynthLocation(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
1212
any(DataFlow::Node n).hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn) and
1313
// avoid overlap with existing DB locations
14-
not exists(File f |
15-
locations_default(_, f, startline, startcolumn, endline, endcolumn) and
16-
f.getAbsolutePath() = filepath
17-
)
14+
not existingDBLocation(filepath, startline, startcolumn, endline, endcolumn)
1815
}
1916

17+
pragma[nomagic]
18+
private predicate existingDBLocation(
19+
string filepath, int startline, int startcolumn, int endline, int endcolumn
20+
) {
21+
exists(File f |
22+
locations_default(_, f, startline, startcolumn, endline, endcolumn) and
23+
f.getAbsolutePath() = filepath
24+
)
25+
}
26+
2027
/**
2128
* A location as given by a file, a start line, a start column,
2229
* an end line, and an end column.

0 commit comments

Comments
 (0)