summaryrefslogtreecommitdiff
path: root/src/ir/branch-utils.h
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2022-05-05 17:50:17 -0700
committerGitHub <noreply@github.com>2022-05-06 00:50:17 +0000
commit0183830cf2976e0930fa45b651be693853f0199a (patch)
tree2e87c373b7ea44a57aa7ade45a831e20b0272324 /src/ir/branch-utils.h
parent8554428d4b26865c03bafa3dbe61ee4fb2957fe1 (diff)
downloadbinaryen-0183830cf2976e0930fa45b651be693853f0199a.tar.gz
binaryen-0183830cf2976e0930fa45b651be693853f0199a.tar.bz2
binaryen-0183830cf2976e0930fa45b651be693853f0199a.zip
[NFC] Avoid scanning code in hasBranchTarget if the target is null (#4648)
A null target is not a valid name so nothing can branch to there. This just saves the wasted work. No existing code in the codebase benefits from this atm, but a later PR will. In particular this lets callers call this without checking if the name is non-null, which is more concise.
Diffstat (limited to 'src/ir/branch-utils.h')
-rw-r--r--src/ir/branch-utils.h4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/ir/branch-utils.h b/src/ir/branch-utils.h
index 58daf5e84..82a563498 100644
--- a/src/ir/branch-utils.h
+++ b/src/ir/branch-utils.h
@@ -237,6 +237,10 @@ inline NameSet getBranchTargets(Expression* ast) {
// Check if an expression defines a particular name as a branch target anywhere
// inside it.
inline bool hasBranchTarget(Expression* ast, Name target) {
+ if (!target.is()) {
+ return false;
+ }
+
struct Scanner
: public PostWalker<Scanner, UnifiedExpressionVisitor<Scanner>> {
Name target;