Skip to content

Commit a7ea730

Browse files
author
Max Schaefer
committed
JavaScript: Fold a predicate to improve performance in the presence of many configurations with many sources/sinks.
1 parent 9a64224 commit a7ea730

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

javascript/ql/src/semmle/javascript/dataflow/Configuration.qll

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -749,13 +749,18 @@ private predicate onPath(DataFlow::Node nd, DataFlow::Configuration cfg, PathSum
749749
)
750750
}
751751

752+
/**
753+
* Holds if `cfg` has at least one source and at least one sink.
754+
*/
755+
pragma[noinline]
756+
private predicate isLive(DataFlow::Configuration cfg) { isSource(_, cfg, _) and isSink(_, cfg, _) }
757+
752758
/**
753759
* A data flow node on an inter-procedural path from a source.
754760
*/
755761
private newtype TPathNode =
756762
MkPathNode(DataFlow::Node nd, DataFlow::Configuration cfg, PathSummary summary) {
757-
isSource(_, cfg, _) and
758-
isSink(_, cfg, _) and
763+
isLive(cfg) and
759764
onPath(nd, cfg, summary)
760765
}
761766

@@ -791,9 +796,7 @@ class PathNode extends TPathNode {
791796
DataFlow::Configuration getConfiguration() { result = cfg }
792797

793798
/** Gets the summary of the path underlying this path node. */
794-
PathSummary getPathSummary() {
795-
result = summary
796-
}
799+
PathSummary getPathSummary() { result = summary }
797800

798801
/** Gets a successor node of this path node. */
799802
PathNode getASuccessor() {

0 commit comments

Comments
 (0)