use boost::small_vector in cppuhelper

shaves 5% off startup time

Change-Id: I901e1112727eb7a50f70d1853386e0696fee7e5e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/167000
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Jenkins
This commit is contained in:
Noel Grandin 2024-05-02 10:44:45 +02:00 committed by Noel Grandin
parent b7ba358d48
commit 5edaca5c89
3 changed files with 10 additions and 12 deletions

View file

@ -39,6 +39,10 @@ $(eval $(call gb_Library_use_static_libraries,cppuhelper,\
findsofficepath \
))
$(eval $(call gb_Library_use_externals,cppuhelper,\
boost_headers \
))
ifeq ($(OS),iOS)
$(eval $(call gb_Library_add_cxxflags,cppuhelper,\
$(gb_OBJCXXFLAGS) \

View file

@ -68,10 +68,7 @@ void insertImplementationMap(
assert(destination != nullptr);
for (const auto& [rName, rImpls] : source)
{
std::vector<
std::shared_ptr<
cppuhelper::ServiceManager::Data::Implementation > > & impls
= (*destination)[rName];
auto & impls = (*destination)[rName];
impls.insert(impls.end(), rImpls.begin(), rImpls.end());
}
}
@ -87,13 +84,9 @@ void removeFromImplementationMap(
assert(map != nullptr);
for (const auto& rElement : elements)
{
cppuhelper::ServiceManager::Data::ImplementationMap::iterator j(
map->find(rElement));
auto j(map->find(rElement));
assert(j != map->end());
std::vector<
std::shared_ptr<
cppuhelper::ServiceManager::Data::Implementation > >::iterator
k(std::find(j->second.begin(), j->second.end(), implementation));
auto k(std::find(j->second.begin(), j->second.end(), implementation));
assert(k != j->second.end());
j->second.erase(k);
if (j->second.empty()) {
@ -1139,7 +1132,7 @@ css::uno::Reference< css::container::XEnumeration >
cppuhelper::ServiceManager::createContentEnumeration(
OUString const & aServiceName)
{
std::vector< std::shared_ptr< Data::Implementation > > impls;
boost::container::small_vector< std::shared_ptr< Data::Implementation >, 2 > impls;
{
std::unique_lock g(m_aMutex);
Data::ImplementationMap::const_iterator i(

View file

@ -32,6 +32,7 @@
#include <com/sun/star/uno/Reference.hxx>
#include <compbase2.hxx>
#include <rtl/ustring.hxx>
#include <boost/container/small_vector.hpp>
namespace com::sun::star::lang {
class XSingleComponentFactory;
@ -174,7 +175,7 @@ public:
typedef
std::unordered_map<
OUString,
std::vector< std::shared_ptr< Implementation > > >
boost::container::small_vector< std::shared_ptr< Implementation >, 2 > >
ImplementationMap;
NamedImplementations namedImplementations;