Improve performance of HereDoc::getBody()

Gets rid of
```
[2021-03-23 10:07:49] (138s) Tuple counts for Literal::HereDoc::getBody_dispred#ff#shared#1/4@1cc5b9:
                      11294    ~0%        {1} r1 = SCAN AST::Cached::THereDoc#ff@staged_ext OUTPUT In.0
                      11294    ~388%      {1} r2 = JOIN r1 WITH Literal::HereDoc::getBody_dispred#ff#join_rhs ON FIRST 1 OUTPUT Rhs.1 'arg1'
                      95514613 ~2080%     {4} r3 = JOIN r2 WITH locations_default_1023#join_rhs ON FIRST 1 OUTPUT Rhs.1 'arg0', Lhs.0 'arg1', Rhs.2 'arg2', Rhs.3 'arg3'
```
This commit is contained in:
Tom Hvitved
2021-03-23 10:31:48 +01:00
parent b293522710
commit 2891d94f99

View File

@@ -523,6 +523,16 @@ class CharacterLiteral extends Literal, TCharacterLiteral {
final override string getAPrimaryQlClass() { result = "CharacterLiteral" }
}
pragma[noinline]
private predicate rankHeredocBody(File f, Generated::HeredocBody b, int i) {
b =
rank[i](Generated::HeredocBody b0 |
f = b0.getLocation().getFile()
|
b0 order by b0.getLocation().getStartLine(), b0.getLocation().getStartColumn()
)
}
/**
* A "here document". For example:
* ```rb
@@ -589,12 +599,7 @@ class HereDoc extends StringlikeLiteral, THereDoc {
|
b order by b.getLocation().getStartLine(), b.getLocation().getStartColumn()
) and
result =
rank[i](Generated::HeredocBody b |
f = b.getLocation().getFile()
|
b order by b.getLocation().getStartLine(), b.getLocation().getStartColumn()
)
rankHeredocBody(f, result, i)
)
}