Hoist strlen out of loop in SkRuntimeEffect::find*

Change-Id: Iedc8242167ac0dedc177511eb75e9e85002799f4
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/414905
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: John Stiles <johnstiles@google.com>
This commit is contained in:
Brian Osman 2021-06-02 12:54:03 -04:00 committed by Skia Commit-Bot
parent 661b5d0e87
commit ee0d18add1

View File

@ -411,14 +411,20 @@ size_t SkRuntimeEffect::uniformSize() const {
}
const SkRuntimeEffect::Uniform* SkRuntimeEffect::findUniform(const char* name) const {
auto iter = std::find_if(fUniforms.begin(), fUniforms.end(),
[name](const Uniform& u) { return u.name.equals(name); });
SkASSERT(name);
size_t len = strlen(name);
auto iter = std::find_if(fUniforms.begin(), fUniforms.end(), [name, len](const Uniform& u) {
return u.name.equals(name, len);
});
return iter == fUniforms.end() ? nullptr : &(*iter);
}
const SkRuntimeEffect::Child* SkRuntimeEffect::findChild(const char* name) const {
auto iter = std::find_if(fChildren.begin(), fChildren.end(),
[name](const Child& c) { return c.name.equals(name); });
SkASSERT(name);
size_t len = strlen(name);
auto iter = std::find_if(fChildren.begin(), fChildren.end(), [name, len](const Child& c) {
return c.name.equals(name, len);
});
return iter == fChildren.end() ? nullptr : &(*iter);
}