Use erase-remove idiom for dead-variable removal.
Change-Id: Ief9aa9aa035424573533072af2c0cd8cee5bf9b4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/314460 Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: John Stiles <johnstiles@google.com>
This commit is contained in:
parent
7954d6c77c
commit
4202dc47a4
@ -1671,14 +1671,13 @@ bool Compiler::optimize(Program& program) {
|
|||||||
for (auto iter = program.fElements.begin(); iter != program.fElements.end();) {
|
for (auto iter = program.fElements.begin(); iter != program.fElements.end();) {
|
||||||
if ((*iter)->fKind == ProgramElement::kVar_Kind) {
|
if ((*iter)->fKind == ProgramElement::kVar_Kind) {
|
||||||
VarDeclarations& vars = (*iter)->as<VarDeclarations>();
|
VarDeclarations& vars = (*iter)->as<VarDeclarations>();
|
||||||
for (auto varIter = vars.fVars.begin(); varIter != vars.fVars.end();) {
|
vars.fVars.erase(
|
||||||
const Variable& var = *(*varIter)->as<VarDeclaration>().fVar;
|
std::remove_if(vars.fVars.begin(), vars.fVars.end(),
|
||||||
if (var.dead()) {
|
[](const std::unique_ptr<Statement>& stmt) {
|
||||||
varIter = vars.fVars.erase(varIter);
|
return stmt->as<VarDeclaration>().fVar->dead();
|
||||||
} else {
|
}),
|
||||||
++varIter;
|
vars.fVars.end());
|
||||||
}
|
|
||||||
}
|
|
||||||
if (vars.fVars.size() == 0) {
|
if (vars.fVars.size() == 0) {
|
||||||
iter = program.fElements.erase(iter);
|
iter = program.fElements.erase(iter);
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user