[Libreoffice-commits] .: sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Wed Dec 8 14:14:12 PST 2010


 sc/source/filter/excel/xichart.cxx |   14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

New commits:
commit ff67d07b5dfc0e77c3ec031b3f397aa7186e80b8
Author: Kohei Yoshida <kyoshida at novell.com>
Date:   Wed Dec 8 17:13:56 2010 -0500

    Slightly more efficient insertion for std::map.

diff --git a/sc/source/filter/excel/xichart.cxx b/sc/source/filter/excel/xichart.cxx
index 04ce91f..323b1f7 100644
--- a/sc/source/filter/excel/xichart.cxx
+++ b/sc/source/filter/excel/xichart.cxx
@@ -3682,12 +3682,14 @@ void XclImpChChart::ReadChDefaultText( XclImpStream& rStrm )
     {
         XclImpChTextRef xText( new XclImpChText( GetChRoot() ) );
         xText->ReadRecordGroup( rStrm );
-        XclImpChTextMap::iterator itr = maDefTexts.find(nTextId);
-        if (itr != maDefTexts.end())
-            // Remove existing element before inserting a new one.
-            maDefTexts.erase(itr);
-
-        maDefTexts.insert(XclImpChTextMap::value_type(nTextId, xText));
+        XclImpChTextMap::iterator itr = maDefTexts.lower_bound(nTextId);
+        if (itr != maDefTexts.end() && !(maDefTexts.key_comp()(nTextId, itr->first)))
+        {
+            // Key exists. Update the existing element.
+            itr->second = xText;
+        }
+        else
+            maDefTexts.insert(itr, XclImpChTextMap::value_type(nTextId, xText));
     }
 }
 


More information about the Libreoffice-commits mailing list