Skip to content

Commit 3991dc3

Browse files
committed
Rust: improve performance of Crate::toString
1 parent 66ab3a8 commit 3991dc3

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

rust/ql/lib/codeql/rust/elements/internal/CrateImpl.qll

+12-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,18 @@ private import codeql.rust.elements.internal.generated.Crate
1212
*/
1313
module Impl {
1414
class Crate extends Generated::Crate {
15-
override string toString() {
16-
result = "Crate(" + this.getName() + "@" + concat(this.getVersion()) + ")"
15+
override string toString() { result = strictconcat(int i | | this.toStringPart(i) order by i) }
16+
17+
private string toStringPart(int i) {
18+
i = 0 and result = "Crate("
19+
or
20+
i = 1 and result = this.getName()
21+
or
22+
i = 2 and result = "@"
23+
or
24+
i = 3 and result = this.getVersion()
25+
or
26+
i = 4 and result = ")"
1727
}
1828
}
1929
}

0 commit comments

Comments
 (0)