diff options
-rw-r--r-- | src/pass.h | 8 | ||||
-rw-r--r-- | src/passes/Asyncify.cpp | 12 | ||||
-rw-r--r-- | src/passes/Directize.cpp | 3 | ||||
-rw-r--r-- | src/passes/LegalizeJSInterface.cpp | 8 |
4 files changed, 13 insertions, 18 deletions
diff --git a/src/pass.h b/src/pass.h index 99b3fb4e2..120ed2629 100644 --- a/src/pass.h +++ b/src/pass.h @@ -188,7 +188,7 @@ struct PassOptions { bool debugInfo = false; // Arbitrary string arguments from the commandline, which we forward to // passes. - std::map<std::string, std::string> arguments; + std::unordered_map<std::string, std::string> arguments; // Effect info computed for functions. One pass can generate this and then // other passes later can benefit from it. It is up to the sequence of passes @@ -217,15 +217,17 @@ struct PassOptions { return PassOptions(); // defaults are to not optimize } + bool hasArgument(std::string key) { return arguments.count(key) > 0; } + std::string getArgument(std::string key, std::string errorTextIfMissing) { - if (arguments.count(key) == 0) { + if (!hasArgument(key)) { Fatal() << errorTextIfMissing; } return arguments[key]; } std::string getArgumentOrDefault(std::string key, std::string default_) { - if (arguments.count(key) == 0) { + if (!hasArgument(key)) { return default_; } return arguments[key]; diff --git a/src/passes/Asyncify.cpp b/src/passes/Asyncify.cpp index 661086408..342cd013d 100644 --- a/src/passes/Asyncify.cpp +++ b/src/passes/Asyncify.cpp @@ -1537,7 +1537,7 @@ struct Asyncify : public Pass { // canIndirectChangeState is the default. asyncify-ignore-indirect sets it // to false. auto canIndirectChangeState = - options.getArgumentOrDefault("asyncify-ignore-indirect", "") == ""; + !options.hasArgument("asyncify-ignore-indirect"); std::string removeListInput = options.getArgumentOrDefault("asyncify-removelist", ""); if (removeListInput.empty()) { @@ -1558,12 +1558,10 @@ struct Asyncify : public Pass { } String::Split onlyList( String::trim(read_possible_response_file(onlyListInput)), ","); - auto asserts = options.getArgumentOrDefault("asyncify-asserts", "") != ""; - auto verbose = options.getArgumentOrDefault("asyncify-verbose", "") != ""; - auto relocatable = - options.getArgumentOrDefault("asyncify-relocatable", "") != ""; - auto secondaryMemory = - options.getArgumentOrDefault("asyncify-in-secondary-memory", "") != ""; + auto asserts = options.hasArgument("asyncify-asserts"); + auto verbose = options.hasArgument("asyncify-verbose"); + auto relocatable = options.hasArgument("asyncify-relocatable"); + auto secondaryMemory = options.hasArgument("asyncify-in-secondary-memory"); // Ensure there is a memory, as we need it. if (secondaryMemory) { diff --git a/src/passes/Directize.cpp b/src/passes/Directize.cpp index ba99d62e9..21254cda7 100644 --- a/src/passes/Directize.cpp +++ b/src/passes/Directize.cpp @@ -208,8 +208,7 @@ struct Directize : public Pass { // TODO: consider a per-table option here auto initialContentsImmutable = - getPassOptions().getArgumentOrDefault( - "directize-initial-contents-immutable", "") != ""; + getPassOptions().hasArgument("directize-initial-contents-immutable"); // Set up the initial info. TableInfoMap tables; diff --git a/src/passes/LegalizeJSInterface.cpp b/src/passes/LegalizeJSInterface.cpp index f5dbbcf62..9732738d6 100644 --- a/src/passes/LegalizeJSInterface.cpp +++ b/src/passes/LegalizeJSInterface.cpp @@ -62,13 +62,9 @@ struct LegalizeJSInterface : public Pass { setTempRet0 = nullptr; getTempRet0 = nullptr; auto exportOriginals = - !getPassOptions() - .getArgumentOrDefault("legalize-js-interface-export-originals", "") - .empty(); + getPassOptions().hasArgument("legalize-js-interface-export-originals"); exportedHelpers = - !getPassOptions() - .getArgumentOrDefault("legalize-js-interface-exported-helpers", "") - .empty(); + getPassOptions().hasArgument("legalize-js-interface-exported-helpers"); // for each illegal export, we must export a legalized stub instead std::vector<std::unique_ptr<Export>> newExports; for (auto& ex : module->exports) { |