diff options
author | Noel Grandin <noelgrandin@gmail.com> | 2020-05-13 18:51:35 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2020-05-15 08:48:06 +0200 |
commit | 4f6931d68664237f7f7eb1f55988b713034c77ba (patch) | |
tree | 35b71c92e3d0660890dd79648e9c1c62cdcc1610 /sc | |
parent | 36e62098c8c541c4a3fb63eced591cf29ac56e4a (diff) |
use more try_emplace
specifically looking for the pattern
if (map.find(...) == map.end()
map[...] = value
Change-Id: I99f20d73f6e71a10726c9d39d8644c2e51120091
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94151
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/oox/stylesbuffer.cxx | 3 | ||||
-rw-r--r-- | sc/source/ui/unoobj/chart2uno.cxx | 6 |
2 files changed, 3 insertions, 6 deletions
diff --git a/sc/source/filter/oox/stylesbuffer.cxx b/sc/source/filter/oox/stylesbuffer.cxx index de613565fd0f..0895f87a2f98 100644 --- a/sc/source/filter/oox/stylesbuffer.cxx +++ b/sc/source/filter/oox/stylesbuffer.cxx @@ -2614,8 +2614,7 @@ void CellStyleBuffer::finalizeImport() { aUnusedName = aStyleName + OUStringChar(' ') + OUString::number( ++nIndex ); } - while( aCellStyles.find( aUnusedName ) != aCellStyles.end() ); - aCellStyles[ aUnusedName ] = rxStyle; + while( !aCellStyles.try_emplace( aUnusedName, rxStyle ).second ); } // set final names and create user-defined and modified built-in cell styles diff --git a/sc/source/ui/unoobj/chart2uno.cxx b/sc/source/ui/unoobj/chart2uno.cxx index 1c5854479125..cdb8303adc7c 100644 --- a/sc/source/ui/unoobj/chart2uno.cxx +++ b/sc/source/ui/unoobj/chart2uno.cxx @@ -781,8 +781,7 @@ void Chart2Positioner::createPositionMap() { FormulaTokenMap& rCol = aCols.begin()->second; if (mbDummyUpperLeft) - if (rCol.find(0) == rCol.end()) - rCol[ 0 ] = nullptr; // dummy for labeling + rCol.try_emplace( 0, nullptr ); // dummy for labeling nAllRowCount = static_cast<SCSIZE>(rCol.size()); } @@ -797,8 +796,7 @@ void Chart2Positioner::createPositionMap() for (auto& rEntry : aCols) { FormulaTokenMap& rCol = rEntry.second; - if (rCol.find(nKey) == rCol.end()) - rCol[ nKey ] = nullptr; + rCol.try_emplace( nKey, nullptr ); } } } |