Ruby: Fix performance problem in Definitions.ql

This commit is contained in:
Tom Hvitved
2021-11-12 14:35:16 +01:00
parent 55ea715ce9
commit 3471e757f2

View File

@@ -65,6 +65,13 @@ newtype DefLoc =
not exists(MethodBase m | m.getAChild+() = write)
}
pragma[noinline]
ConstantWriteAccess definitionOf0(string fqn) {
fqn = resolveConstant(_) and
result =
min(ConstantWriteAccess w | w.getQualifiedName() = fqn | w order by w.getLocation().toString())
}
/**
* Gets the constant write that defines the given constant.
* Modules often don't have a unique definition, as they are opened multiple times in different
@@ -72,10 +79,5 @@ newtype DefLoc =
* location.
*/
ConstantWriteAccess definitionOf(ConstantReadAccess r) {
result =
min(ConstantWriteAccess w |
w.getQualifiedName() = resolveConstant(r)
|
w order by w.getLocation().toString()
)
result = definitionOf0(resolveConstant(r))
}