[Libreoffice-commits] core.git: stoc/source
Arkadiy Illarionov (via logerrit)
logerrit at kemper.freedesktop.org
Thu Aug 15 21:46:00 UTC 2019
stoc/source/defaultregistry/defaultregistry.cxx | 24 +++++++++---------------
1 file changed, 9 insertions(+), 15 deletions(-)
New commits:
commit 3e64065612acec2eb29aa21e2b515953422256d7
Author: Arkadiy Illarionov <qarkai at gmail.com>
AuthorDate: Wed Aug 14 22:27:06 2019 +0300
Commit: Arkadiy Illarionov <qarkai at gmail.com>
CommitDate: Thu Aug 15 23:44:41 2019 +0200
Optimize NestedKeyImpl::openKeys
* Use const methods of Sequence
* Get rid of extra loop over localSeq
* Simplify default keys insert condition
Change-Id: I112c0a53d3ebfc2ff54a4ac904e6e112beaf3cdd
Reviewed-on: https://gerrit.libreoffice.org/77472
Tested-by: Jenkins
Reviewed-by: Arkadiy Illarionov <qarkai at gmail.com>
diff --git a/stoc/source/defaultregistry/defaultregistry.cxx b/stoc/source/defaultregistry/defaultregistry.cxx
index bfa698b13b91..71a637309c5a 100644
--- a/stoc/source/defaultregistry/defaultregistry.cxx
+++ b/stoc/source/defaultregistry/defaultregistry.cxx
@@ -755,33 +755,27 @@ Sequence< Reference< XRegistryKey > > SAL_CALL NestedKeyImpl::openKeys( )
defaultSeq = m_defaultKey->getKeyNames();
}
- sal_uInt32 local = localSeq.getLength();
- sal_uInt32 def = defaultSeq.getLength();
- sal_uInt32 len = static_cast<sal_uInt32>(std::count_if(localSeq.begin(), localSeq.end(),
- [&defaultSeq](const OUString& rLocal) { return comphelper::findValue(defaultSeq, rLocal) != -1; }));
-
- Sequence< Reference<XRegistryKey> > retSeq(local + def - len);
+ std::vector< Reference<XRegistryKey> > retVec;
+ retVec.reserve(localSeq.getLength() + defaultSeq.getLength());
auto lKeyNameToRegKey = [this](const OUString& rName) -> Reference<XRegistryKey> {
sal_Int32 lastIndex = rName.lastIndexOf('/');
OUString name = rName.copy(lastIndex);
return new NestedKeyImpl(name, this);
};
- std::transform(localSeq.begin(), localSeq.end(), retSeq.begin(), lKeyNameToRegKey);
- sal_uInt32 k = local;
- for (const auto& rDef : std::as_const(defaultSeq))
- {
- bool insert = std::none_of(retSeq.begin(), std::next(retSeq.begin(), local),
- [&rDef](const Reference<XRegistryKey>& rKey) { return rKey->getKeyName() == rDef; });
+ for (const auto& rKeyName : std::as_const(localSeq))
+ retVec.push_back(lKeyNameToRegKey(rKeyName));
- if ( insert )
+ for (const auto& rKeyName : std::as_const(defaultSeq))
+ {
+ if ( comphelper::findValue(localSeq, rKeyName) == -1 )
{
- retSeq.getArray()[k++] = lKeyNameToRegKey(rDef);
+ retVec.push_back(lKeyNameToRegKey(rKeyName));
}
}
- return retSeq;
+ return comphelper::containerToSequence(retVec);
}
More information about the Libreoffice-commits
mailing list