From 2e76c925ce0f1271f5604443b17d1786e94a9055 Mon Sep 17 00:00:00 2001 From: Kyle Cripps Date: Fri, 12 Jul 2024 22:21:37 -0700 Subject: [PATCH] Short-circuit when parents are equal Signed-off-by: Kyle Cripps --- frontends/p4/def_use.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/frontends/p4/def_use.h b/frontends/p4/def_use.h index 0800e09185..4343c2a153 100644 --- a/frontends/p4/def_use.h +++ b/frontends/p4/def_use.h @@ -41,8 +41,9 @@ struct loc_t { const loc_t *parent; bool operator==(const loc_t &a) const { if (node != a.node) return false; - if (parent && a.parent) return *parent == *a.parent; - return parent == a.parent; + if (parent == a.parent) return true; + if (!parent || !a.parent) return false; + return *parent == *a.parent; } std::size_t hash() const; };