summaryrefslogtreecommitdiff
path: root/src/passes/SimplifyLocals.cpp
diff options
context:
space:
mode:
authorMax Graey <maxgraey@gmail.com>2021-11-23 07:03:25 +0200
committerGitHub <noreply@github.com>2021-11-22 21:03:25 -0800
commit7f24fce21a92f2aed4a11745d27d5181798ba6cd (patch)
tree80655dc933e3c2ae3ae53b7960cd71a6a022c3da /src/passes/SimplifyLocals.cpp
parent37999167bb333dd0b12d744af8e633897e65cff8 (diff)
downloadbinaryen-7f24fce21a92f2aed4a11745d27d5181798ba6cd.tar.gz
binaryen-7f24fce21a92f2aed4a11745d27d5181798ba6cd.tar.bz2
binaryen-7f24fce21a92f2aed4a11745d27d5181798ba6cd.zip
Modernize code to C++17 (#3104)
Diffstat (limited to 'src/passes/SimplifyLocals.cpp')
-rw-r--r--src/passes/SimplifyLocals.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/passes/SimplifyLocals.cpp b/src/passes/SimplifyLocals.cpp
index 7c768d4d4..8ed822774 100644
--- a/src/passes/SimplifyLocals.cpp
+++ b/src/passes/SimplifyLocals.cpp
@@ -280,9 +280,9 @@ struct SimplifyLocals
void checkInvalidations(EffectAnalyzer& effects) {
// TODO: this is O(bad)
std::vector<Index> invalidated;
- for (auto& sinkable : sinkables) {
- if (effects.invalidates(sinkable.second.effects)) {
- invalidated.push_back(sinkable.first);
+ for (auto& [index, info] : sinkables) {
+ if (effects.invalidates(info.effects)) {
+ invalidated.push_back(index);
}
}
for (auto index : invalidated) {
@@ -303,9 +303,9 @@ struct SimplifyLocals
// 'try', we drop all sinkables that may throw.
if (curr->is<Try>()) {
std::vector<Index> invalidated;
- for (auto& sinkable : self->sinkables) {
- if (sinkable.second.effects.throws) {
- invalidated.push_back(sinkable.first);
+ for (auto& [index, info] : self->sinkables) {
+ if (info.effects.throws) {
+ invalidated.push_back(index);
}
}
for (auto index : invalidated) {
@@ -407,9 +407,9 @@ struct SimplifyLocals
if (set && self->canSink(set)) {
Index index = set->index;
assert(self->sinkables.count(index) == 0);
- self->sinkables.emplace(std::make_pair(
+ self->sinkables.emplace(std::pair{
index,
- SinkableInfo(currp, self->getPassOptions(), *self->getModule())));
+ SinkableInfo(currp, self->getPassOptions(), *self->getModule())});
}
if (!allowNesting) {
@@ -493,8 +493,7 @@ struct SimplifyLocals
// look for a local.set that is present in them all
bool found = false;
Index sharedIndex = -1;
- for (auto& sinkable : sinkables) {
- Index index = sinkable.first;
+ for (auto& [index, _] : sinkables) {
bool inAll = true;
for (size_t j = 0; j < breaks.size(); j++) {
if (breaks[j].sinkables.count(index) == 0) {
@@ -648,8 +647,7 @@ struct SimplifyLocals
}
} else {
// Look for a shared index.
- for (auto& sinkable : ifTrue) {
- Index index = sinkable.first;
+ for (auto& [index, _] : ifTrue) {
if (ifFalse.count(index) > 0) {
goodIndex = index;
found = true;