summaryrefslogtreecommitdiff
path: root/src/passes/CodePushing.cpp
diff options
context:
space:
mode:
authorjuj <jujjyl@gmail.com>2022-04-05 23:01:03 +0300
committerGitHub <noreply@github.com>2022-04-05 13:01:03 -0700
commitcbc7e0455dcef0a7df6e4ab345626b8e69534f7f (patch)
tree99bccfd29c3e8cf1d31d56b1934b566f92b54f74 /src/passes/CodePushing.cpp
parent291698fe1b5512d72186dfc2400bca85dcb507b1 (diff)
downloadbinaryen-cbc7e0455dcef0a7df6e4ab345626b8e69534f7f.tar.gz
binaryen-cbc7e0455dcef0a7df6e4ab345626b8e69534f7f.tar.bz2
binaryen-cbc7e0455dcef0a7df6e4ab345626b8e69534f7f.zip
Avoid a code pattern of vec.resize() followed by std::fill() as suboptimal. Instead do a clear()+resize() (#4580)
Diffstat (limited to 'src/passes/CodePushing.cpp')
-rw-r--r--src/passes/CodePushing.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/passes/CodePushing.cpp b/src/passes/CodePushing.cpp
index 3ac11eebd..29a3ae743 100644
--- a/src/passes/CodePushing.cpp
+++ b/src/passes/CodePushing.cpp
@@ -41,12 +41,12 @@ struct LocalAnalyzer : public PostWalker<LocalAnalyzer> {
void analyze(Function* func) {
auto num = func->getNumLocals();
+ numSets.clear();
numSets.resize(num);
- std::fill(numSets.begin(), numSets.end(), 0);
+ numGets.clear();
numGets.resize(num);
- std::fill(numGets.begin(), numGets.end(), 0);
+ sfa.clear();
sfa.resize(num);
- std::fill(sfa.begin(), sfa.begin() + func->getNumParams(), false);
std::fill(sfa.begin() + func->getNumParams(), sfa.end(), true);
walk(func->body);
for (Index i = 0; i < num; i++) {
@@ -245,8 +245,8 @@ struct CodePushing : public WalkerPass<PostWalker<CodePushing>> {
// pre-scan to find which vars are sfa, and also count their gets&sets
analyzer.analyze(func);
// prepare to walk
+ numGetsSoFar.clear();
numGetsSoFar.resize(func->getNumLocals());
- std::fill(numGetsSoFar.begin(), numGetsSoFar.end(), 0);
// walk and optimize
walk(func->body);
}