From 261b2f1f2bc13ccf7db5ec68c825ffc7b0781f7f Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 12 Jul 2023 16:00:05 -0700 Subject: Use scratchData on `IRInst` to replace HashSets. (#2978) * Use scratchData on `IRInst` to replace HashSets. * Update test results. * Initialize scratchData. * Update autodiff documentation. * Use enum instead of bool. --------- Co-authored-by: Yong He --- source/slang/slang-ast-builder.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-ast-builder.cpp') diff --git a/source/slang/slang-ast-builder.cpp b/source/slang/slang-ast-builder.cpp index 33bd23f43..e6e1b5e75 100644 --- a/source/slang/slang-ast-builder.cpp +++ b/source/slang/slang-ast-builder.cpp @@ -445,6 +445,7 @@ TypeType* ASTBuilder::getTypeType(Type* type) bool ASTBuilder::NodeDesc::operator==(NodeDesc const& that) const { + if (hashCode != that.hashCode) return false; if(type != that.type) return false; if(operands.getCount() != that.operands.getCount()) return false; for(Index i = 0; i < operands.getCount(); ++i) @@ -461,7 +462,8 @@ bool ASTBuilder::NodeDesc::operator==(NodeDesc const& that) const } return true; } -HashCode ASTBuilder::NodeDesc::getHashCode() const + +void ASTBuilder::NodeDesc::init() { Hasher hasher; hasher.hashValue(Int(type)); @@ -474,7 +476,7 @@ HashCode ASTBuilder::NodeDesc::getHashCode() const // hasher.hashValue(operands[i].values.nodeOperand); } - return hasher.getResult(); + hashCode = hasher.getResult(); } DeclRef _getSpecializedDeclRef(ASTBuilder* builder, Decl* decl, Substitutions* subst) -- cgit v1.2.3