Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e7de40d9 authored by Yurii Zubrytskyi's avatar Yurii Zubrytskyi
Browse files

Clean up the attribute searching func

Don't convert each attribute name but instead only
do it once for the string they're compared to

Bug: 282215580
Test: build + atest idmap2_tests
Change-Id: I09f6d0f90f6c09632ceac8cdde7c20801f41524e
parent 98b8623c
Loading
Loading
Loading
Loading
+7 −4
Original line number Diff line number Diff line
@@ -130,11 +130,14 @@ Result<Res_value> XmlParser::Node::GetAttributeValue(ResourceId attr,
}

Result<Res_value> XmlParser::Node::GetAttributeValue(const std::string& name) const {
  String16 name16;
  return FindAttribute(parser_, name, [&](size_t index) -> bool {
    size_t len;
    const String16 key16(parser_.getAttributeName(index, &len));
    std::string key = String8(key16).c_str();
    return key == name;
    if (name16.empty()) {
        name16 = String16(name.c_str(), name.size());
    }
    size_t key_len;
    const auto key16 = parser_.getAttributeName(index, &key_len);
    return key16 && name16.size() == key_len && name16 == key16;
  });
}