summaryrefslogtreecommitdiff
path: root/comphelper/source
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-08-10 19:54:28 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-08-11 13:23:08 +0200
commitd39d87bbffe8e731bad92f2fe90526c3610689f5 (patch)
treefb78eb13d9e889be97bd8f47605cd7002d60404f /comphelper/source
parent56ba9c544d2e5dce9022a245a6835d79bbf0f31d (diff)
no need to allocate KeyedValues separately
Change-Id: If28471436d224e88dfee07f3b8465648867197fd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/120291 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'comphelper/source')
-rw-r--r--comphelper/source/container/enumerablemap.cxx7
1 files changed, 4 insertions, 3 deletions
diff --git a/comphelper/source/container/enumerablemap.cxx b/comphelper/source/container/enumerablemap.cxx
index ae6053d7520c..a8897c293da4 100644
--- a/comphelper/source/container/enumerablemap.cxx
+++ b/comphelper/source/container/enumerablemap.cxx
@@ -39,6 +39,7 @@
#include <cmath>
#include <map>
#include <memory>
+#include <optional>
#include <utility>
namespace comphelper
@@ -89,7 +90,7 @@ namespace comphelper
{
Type m_aKeyType;
Type m_aValueType;
- std::unique_ptr< KeyedValues > m_pValues;
+ std::optional< KeyedValues > m_pValues;
std::shared_ptr< IKeyPredicateLess > m_pKeyCompare;
bool m_bMutable;
std::vector< MapEnumerator* > m_aModListeners;
@@ -102,11 +103,11 @@ namespace comphelper
MapData( const MapData& _source )
:m_aKeyType( _source.m_aKeyType )
,m_aValueType( _source.m_aValueType )
- ,m_pValues( new KeyedValues( *_source.m_pValues ) )
,m_pKeyCompare( _source.m_pKeyCompare )
,m_bMutable( false )
,m_aModListeners()
{
+ m_pValues.emplace( *_source.m_pValues );
}
private:
MapData& operator=( const MapData& _source ) = delete;
@@ -356,7 +357,7 @@ namespace comphelper
m_aData.m_aKeyType = aKeyType;
m_aData.m_aValueType = aValueType;
m_aData.m_pKeyCompare = std::move(pComparator);
- m_aData.m_pValues.reset( new KeyedValues( *m_aData.m_pKeyCompare ) );
+ m_aData.m_pValues.emplace( *m_aData.m_pKeyCompare );
m_aData.m_bMutable = bMutable;
if ( aInitialValues.hasElements() )