diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-18 15:13:19 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2019-04-19 13:19:31 +0200 |
commit | 1a5b12aa5da2c718848d3cc5d9bce7bfcdeacf54 (patch) | |
tree | 25044edc2afb99073ba6bef8d181dadbb6a53467 /sw/source/filter/ww8/wrtw8sty.cxx | |
parent | eaaaad0e21edb27edaa865eee03696f007cd8010 (diff) |
optimise find/insert pattern
if we're doing a find/insert on a set or a map, it is better to just do
a conditional insert/emplace operation than triggering two lookups.
Change-Id: I80da5097f5a89fe30fa348ce5b6e747c34287a8d
Reviewed-on: https://gerrit.libreoffice.org/70937
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'sw/source/filter/ww8/wrtw8sty.cxx')
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index f7bc5136e922..e4e24952f763 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -353,18 +353,16 @@ void MSWordStyles::BuildStyleIds() OString aLower(aStyleId.toAsciiLowerCase()); // check for uniqueness & construct something unique if we have to - if (aUsed.find(aLower) == aUsed.end()) + if (aUsed.insert(aLower).second) { - aUsed.insert(aLower); m_aStyleIds.push_back(aStyleId); } else { int nFree = 1; - while (aUsed.find(aLower + OString::number(nFree)) != aUsed.end()) + while (!aUsed.insert(aLower + OString::number(nFree)).second) ++nFree; - aUsed.insert(aLower + OString::number(nFree)); m_aStyleIds.emplace_back(aStyleId + OString::number(nFree)); } } |