mirror of
https://github.com/tristanpenman/valijson.git
synced 2024-12-12 10:13:51 +01:00
Add optimization for find implementation.
This commit is contained in:
parent
c688aa3bcb
commit
b685584e42
@ -14,5 +14,4 @@ BraceWrapping:
|
|||||||
IndentBraces: false
|
IndentBraces: false
|
||||||
BreakBeforeBraces: Custom
|
BreakBeforeBraces: Custom
|
||||||
IndentWidth: 4
|
IndentWidth: 4
|
||||||
ColumnLimit: 0
|
|
||||||
AllowShortFunctionsOnASingleLine: Empty
|
AllowShortFunctionsOnASingleLine: Empty
|
||||||
|
@ -681,12 +681,16 @@ inline YamlCppObjectMemberIterator YamlCppObject::end() const
|
|||||||
inline YamlCppObjectMemberIterator
|
inline YamlCppObjectMemberIterator
|
||||||
YamlCppObject::find(const std::string &propertyName) const
|
YamlCppObject::find(const std::string &propertyName) const
|
||||||
{
|
{
|
||||||
// TODO: I'm not sure how to do this in yaml-cpp
|
YAML::Node result = m_value[propertyName];
|
||||||
YAML::const_iterator itr;
|
if (!result.IsDefined())
|
||||||
for (itr = m_value.begin(); itr != m_value.end(); ++itr)
|
return end();
|
||||||
if (itr->first.as<std::string>() == propertyName)
|
|
||||||
return itr;
|
// yaml-cpp does not offer an iterator-based lookup,
|
||||||
return itr;
|
// so instead we create a new placeholder object and
|
||||||
|
// return an iterator to that container instead.
|
||||||
|
YAML::Node wrapper = YAML::Node(YAML::NodeType::Map);
|
||||||
|
wrapper[propertyName] = result;
|
||||||
|
return YamlCppObjectMemberIterator(wrapper.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace adapters
|
} // namespace adapters
|
||||||
|
Loading…
Reference in New Issue
Block a user