summaryrefslogtreecommitdiff
path: root/src/wasm-binary.h
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-11-19 20:59:14 -0800
committerGitHub <noreply@github.com>2020-11-19 20:59:14 -0800
commitde5e7365957b3eaf0d9aa05eea4ee759efb67ca4 (patch)
tree397149ae1909c35fa6851a87c289ec5427f647b2 /src/wasm-binary.h
parentd0bc3811f00fe90762a9bee19bf354f780704ce5 (diff)
downloadbinaryen-de5e7365957b3eaf0d9aa05eea4ee759efb67ca4.tar.gz
binaryen-de5e7365957b3eaf0d9aa05eea4ee759efb67ca4.tar.bz2
binaryen-de5e7365957b3eaf0d9aa05eea4ee759efb67ca4.zip
[wasm-builder] Construct module elements as unique_ptrs (#3391)
When Functions, Globals, Events, and Exports are added to a module, if they are not already in std::unique_ptrs, they are wrapped in a new std::unique_ptr owned by the Module. This adds an extra layer of indirection when accessing those elements that can be avoided by allocating those elements as std::unique_ptrs. This PR updates wasm-builder to allocate module elements via std::make_unique rather than `new`. In the future, we should remove the raw pointer versions of Module::add* to encourage using std::unique_ptrs more broadly.
Diffstat (limited to 'src/wasm-binary.h')
-rw-r--r--src/wasm-binary.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/wasm-binary.h b/src/wasm-binary.h
index 205a9b447..ef3f9c9d1 100644
--- a/src/wasm-binary.h
+++ b/src/wasm-binary.h
@@ -1362,7 +1362,7 @@ public:
Index endOfFunction = -1;
// we store globals here before wasm.addGlobal after we know their names
- std::vector<Global*> globals;
+ std::vector<std::unique_ptr<Global>> globals;
// we store global imports here before wasm.addGlobalImport after we know
// their names
std::vector<Global*> globalImports;