sc/source/core/inc/interpre.hxx |   16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

New commits:
commit 7f9a35e6efc4118ecc46fa6f76fc5a812259eea1
Author:     Noel Grandin <noelgran...@gmail.com>
AuthorDate: Wed Apr 10 12:14:32 2024 +0100
Commit:     Noel Grandin <noel.gran...@collabora.co.uk>
CommitDate: Wed Apr 10 14:50:57 2024 +0200

    use unordered_map for ScTokenMatrixMap
    
    which is considerably faster
    
    Change-Id: Ic44d88d8ef222edd91de8ae0e79d77a99c5c2e95
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165924
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk>

diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 31ff2ecb7a9c..81240095fd98 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -34,7 +34,7 @@
 #include <sortparam.hxx>
 #include "parclass.hxx"
 
-#include <map>
+#include <unordered_map>
 #include <memory>
 #include <vector>
 #include <limits>
@@ -179,18 +179,16 @@ enum ScETSType
     etsStatMult
 };
 
-struct FormulaTokenRef_less
+struct FormulaTokenRef_hash
 {
-    bool operator () ( const formula::FormulaConstTokenRef& r1, const 
formula::FormulaConstTokenRef& r2 ) const
-        { return r1.get() < r2.get(); }
+    bool operator () ( const formula::FormulaConstTokenRef& r1 ) const
+        { return std::hash<const void*>()(static_cast<const void*>(r1.get())); 
}
     // So we don't have to create a FormulaConstTokenRef to search by 
formula::FormulaToken*
     using is_transparent = void;
-    bool operator () ( const formula::FormulaToken* p1, const 
formula::FormulaConstTokenRef& r2 ) const
-        { return p1 < r2.get(); }
-    bool operator () ( const formula::FormulaConstTokenRef& r1, const 
formula::FormulaToken* p2 ) const
-        { return r1.get() < p2; }
+    bool operator () ( const formula::FormulaToken* p1 ) const
+        { return std::hash<const void *>()(static_cast<const void*>(p1)); }
 };
-typedef ::std::map< const formula::FormulaConstTokenRef, 
formula::FormulaConstTokenRef, FormulaTokenRef_less> ScTokenMatrixMap;
+typedef ::std::unordered_map< const formula::FormulaConstTokenRef, 
formula::FormulaConstTokenRef, FormulaTokenRef_hash> ScTokenMatrixMap;
 
 class ScInterpreter
 {

Reply via email to