tint: Replace type::UniqueNode::Hash() virtual with field

Virtual methods are expensive to call, and hashes are frequently tested.
The hash must be immutable, so just calculate it once in the constructor and store it as an immutable field.

Change-Id: I9d29fb3fc074e57e7af91367768a47193baa40f1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/114780
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Auto-Submit: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton
2022-12-19 17:07:29 +00:00
committed by Dawn LUCI CQ
parent ada5e7b0f9
commit ce93a6b224
75 changed files with 169 additions and 397 deletions

View File

@@ -57,11 +57,10 @@ constexpr static const size_t kNumFixedCandidates = 8;
/// A special type that matches all TypeMatchers
class Any final : public Castable<Any, type::Type> {
public:
Any() : Base(type::Flags{}) {}
Any() : Base(0u, type::Flags{}) {}
~Any() override = default;
// Stub implementations for type::Type conformance.
size_t Hash() const override { return 0; }
bool Equals(const type::UniqueNode&) const override { return false; }
std::string FriendlyName(const SymbolTable&) const override { return "<any>"; }
};