Skip to content

Commit 766a338

Browse files
committed
Rust: improve performance of Crate::toString
1 parent 66ab3a8 commit 766a338

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

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

+13-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,19 @@ private import codeql.rust.elements.internal.generated.Crate
1313
module Impl {
1414
class Crate extends Generated::Crate {
1515
override string toString() {
16-
result = "Crate(" + this.getName() + "@" + concat(this.getVersion()) + ")"
16+
result = strictconcat(int i | | this.toStringPart(i), " " order by i)
17+
}
18+
19+
private string toStringPart(int i) {
20+
i = 0 and result = "Crate("
21+
or
22+
i = 1 and result = this.getName()
23+
or
24+
i = 2 and result = "@"
25+
or
26+
i = 3 and result = this.getVersion()
27+
or
28+
i = 4 and result = ")"
1729
}
1830
}
1931
}

0 commit comments

Comments
 (0)