From 0183830cf2976e0930fa45b651be693853f0199a Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 5 May 2022 17:50:17 -0700 Subject: [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. --- src/ir/branch-utils.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/ir/branch-utils.h') 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> { Name target; -- cgit v1.2.3