diff options
author | Arkadiy Illarionov <qarkai@gmail.com> | 2019-08-14 22:27:06 +0300 |
---|---|---|
committer | Arkadiy Illarionov <qarkai@gmail.com> | 2019-08-15 23:44:41 +0200 |
commit | 3e64065612acec2eb29aa21e2b515953422256d7 (patch) | |
tree | 80415757792e2e3f4fb51ec4d53a7705b567869c /stoc | |
parent | 5eeed4ef360ddfefaa489d71da788e1e9f217398 (diff) |
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@gmail.com>
Diffstat (limited to 'stoc')
-rw-r--r-- | stoc/source/defaultregistry/defaultregistry.cxx | 24 |
1 files changed, 9 insertions, 15 deletions
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); } |