[Libreoffice-commits] .: tools/source

Tor Lillqvist tml at kemper.freedesktop.org
Mon Aug 22 09:06:13 PDT 2011


 tools/source/rc/resmgr.cxx |   30 ++++++++++--------------------
 1 file changed, 10 insertions(+), 20 deletions(-)

New commits:
commit f54198869081cda24b3777ce4ac0c6b9458d0ab7
Author: Tor Lillqvist <tlillqvist at novell.com>
Date:   Mon Aug 22 19:02:47 2011 +0300

    Fix dubious std::lower_bound usage that breaks in a _DEBUG MSVC build

diff --git a/tools/source/rc/resmgr.cxx b/tools/source/rc/resmgr.cxx
index c5ff744..b6532d2 100644
--- a/tools/source/rc/resmgr.cxx
+++ b/tools/source/rc/resmgr.cxx
@@ -518,18 +518,6 @@ struct ImpContentLessCompare : public ::std::binary_function< ImpContent, ImpCon
     }
 };
 
-struct ImpContentMixLessCompare : public ::std::binary_function< ImpContent, sal_uInt64, bool>
-{
-    inline bool operator() (const ImpContent& lhs, const sal_uInt64& rhs) const
-    {
-        return lhs.nTypeAndId < rhs;
-    }
-    inline bool operator() (const sal_uInt64& lhs, const ImpContent& rhs) const
-    {
-        return lhs < rhs.nTypeAndId;
-    }
-};
-
 static ResHookProc pImplResHookProc = 0;
 
 InternalResMgr::InternalResMgr( const OUString& rFileURL,
@@ -667,12 +655,13 @@ sal_Bool InternalResMgr::Create()
 sal_Bool InternalResMgr::IsGlobalAvailable( RESOURCE_TYPE nRT, sal_uInt32 nId ) const
 {
     // Anfang der Strings suchen
-    sal_uInt64 nValue = ((sal_uInt64(nRT) << 32) | nId);
+    ImpContent aValue;
+    aValue.nTypeAndId = ((sal_uInt64(nRT) << 32) | nId);
     ImpContent * pFind = ::std::lower_bound(pContent,
                                             pContent + nEntries,
-                                            nValue,
-                                            ImpContentMixLessCompare());
-    return (pFind != (pContent + nEntries)) && (pFind->nTypeAndId == nValue);
+                                            aValue,
+                                            ImpContentLessCompare());
+    return (pFind != (pContent + nEntries)) && (pFind->nTypeAndId == aValue.nTypeAndId);
 }
 
 // -----------------------------------------------------------------------
@@ -685,13 +674,14 @@ void* InternalResMgr::LoadGlobalRes( RESOURCE_TYPE nRT, sal_uInt32 nId,
         pResUseDump->erase( (sal_uInt64(nRT) << 32) | nId );
 #endif
     // Anfang der Strings suchen
-    sal_uInt64 nValue = ((sal_uInt64(nRT) << 32) | nId);
+    ImpContent aValue;
+    aValue.nTypeAndId = ((sal_uInt64(nRT) << 32) | nId);
     ImpContent* pEnd = (pContent + nEntries);
     ImpContent* pFind = ::std::lower_bound( pContent,
                                             pEnd,
-                                            nValue,
-                                            ImpContentMixLessCompare());
-    if( pFind && (pFind != pEnd) && (pFind->nTypeAndId == nValue) )
+                                            aValue,
+                                            ImpContentLessCompare());
+    if( pFind && (pFind != pEnd) && (pFind->nTypeAndId == aValue.nTypeAndId) )
     {
         if( nRT == RSC_STRING && bEqual2Content )
         {


More information about the Libreoffice-commits mailing list