Skip to content

Commit

Permalink
Short-circuit when parents are equal
Browse files Browse the repository at this point in the history
  • Loading branch information
kfcripps committed Jul 13, 2024
1 parent 37072bb commit abfffee
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions frontends/p4/def_use.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Expand Down

0 comments on commit abfffee

Please sign in to comment.