From 79d271580e217a26c355ac58dbf2fb3526f07a04 Mon Sep 17 00:00:00 2001 From: David Neto Date: Fri, 23 Oct 2020 17:04:40 +0000 Subject: [PATCH] Don't leak the array-type memo table. This also keeps tests isolated from each other. Change-Id: I56937bb160138d7d82b2cf8f2560ddb5c0647048 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/30881 Reviewed-by: dan sinclair Commit-Queue: dan sinclair --- src/inspector/inspector_test.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/inspector/inspector_test.cc b/src/inspector/inspector_test.cc index d3873600a3..95a97bb916 100644 --- a/src/inspector/inspector_test.cc +++ b/src/inspector/inspector_test.cc @@ -354,12 +354,11 @@ class InspectorHelper { ast::type::I32Type* i32_type() { return &i32_type_; } ast::type::U32Type* u32_type() { return &u32_type_; } ast::type::ArrayType* u32_array_type(uint32_t count) { - static std::map> memo; - if (memo.find(count) == memo.end()) { - memo[count] = std::make_unique(u32_type(), count); + if (array_type_memo_.find(count) == array_type_memo_.end()) { + array_type_memo_[count] = + std::make_unique(u32_type(), count); } - - return memo[count].get(); + return array_type_memo_[count].get(); } ast::type::VoidType* void_type() { return &void_type_; } @@ -374,6 +373,7 @@ class InspectorHelper { ast::type::I32Type i32_type_; ast::type::U32Type u32_type_; ast::type::VoidType void_type_; + std::map> array_type_memo_; }; class InspectorTest : public InspectorHelper, public testing::Test {};