From bf51d9e613e7cc95f4f3dd942493612c12e7f3f7 Mon Sep 17 00:00:00 2001 From: Alexander McCord Date: Mon, 27 May 2024 21:11:48 -0700 Subject: [PATCH] This really should be an universal reference. --- EqSat/include/Luau/EGraph.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/EqSat/include/Luau/EGraph.h b/EqSat/include/Luau/EGraph.h index 96e0ed3d..efe21aa3 100644 --- a/EqSat/include/Luau/EGraph.h +++ b/EqSat/include/Luau/EGraph.h @@ -40,11 +40,12 @@ struct EGraph final return unionfind.find(id); } - // An e-node 𝑛 is canonical iff 𝑛 = canonicalize(𝑛), where - // canonicalize(𝑓(𝑎1, 𝑎2, ...)) = 𝑓(find(𝑎1), find(𝑎2), ...). - std::optional lookup(L enode) const + template + std::optional lookup(T&& enode) const { - for (Id& id : enode.operands()) + // An e-node 𝑛 is canonical iff 𝑛 = canonicalize(𝑛), where + // canonicalize(𝑓(𝑎1, 𝑎2, ...)) = 𝑓(find(𝑎1), find(𝑎2), ...). + for (Id& id : enode->operands()) id = find(id); if (auto it = hashcons.find(enode); it != hashcons.end())