materialize less strings when ranking states

This commit is contained in:
erik-krogh
2023-03-23 10:35:58 +01:00
parent 3d9bbd7824
commit e189b36e3f
6 changed files with 15 additions and 13 deletions

View File

@@ -147,6 +147,8 @@ module Make<RegexTreeViewSig TreeImpl> {
/**
* Gets a string for the full location of `t`.
*/
bindingset[t]
pragma[inline_late]
string getTermLocationString(RegExpTerm t) {
exists(string file, int startLine, int startColumn, int endLine, int endColumn |
t.hasLocationInfo(file, startLine, startColumn, endLine, endColumn) and

View File

@@ -354,13 +354,13 @@ module Make<RegexTreeViewSig TreeImpl> {
*/
private int rankState(State state) {
state =
rank[result](State s |
exists(StateTuple tuple |
tuple = getARelevantStateTuple(_, _) and
s = [tuple.getFirst(), tuple.getSecond(), tuple.getThird()]
rank[result](State s, int startLine, int endLine, int startColumn, int endColumn |
exists(StateTuple tuple | tuple = getARelevantStateTuple(_, _) |
s = [tuple.getFirst(), tuple.getSecond(), tuple.getThird()] and
s.getRepr().hasLocationInfo(_, startLine, startColumn, endLine, endColumn)
)
|
s order by getTermLocationString(s.getRepr())
s order by startLine, startColumn, endLine, endColumn
)
}