openoffice-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From h..@apache.org
Subject svn commit: r1468373 - /openoffice/trunk/main/animations/source/animcore/targetpropertiescreator.cxx
Date Tue, 16 Apr 2013 11:27:36 GMT
Author: hdu
Date: Tue Apr 16 11:27:35 2013
New Revision: 1468373

URL: http://svn.apache.org/r1468373
Log:
use XShapeHash type to make this *_map compatible with the corresponding TR1 container

The TR1 containers don't support dynamic hash functions provided in their constructor.
Having the hash functor as part the hash container's type is cleaner anyway.

Modified:
    openoffice/trunk/main/animations/source/animcore/targetpropertiescreator.cxx

Modified: openoffice/trunk/main/animations/source/animcore/targetpropertiescreator.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/animations/source/animcore/targetpropertiescreator.cxx?rev=1468373&r1=1468372&r2=1468373&view=diff
==============================================================================
--- openoffice/trunk/main/animations/source/animcore/targetpropertiescreator.cxx (original)
+++ openoffice/trunk/main/animations/source/animcore/targetpropertiescreator.cxx Tue Apr 16
11:27:35 2013
@@ -143,29 +143,29 @@ namespace animcore
             }
         };
 
-        // A hash map which maps a XShape to the corresponding vector of initial properties
-        typedef ::std::hash_map< ShapeHashKey,
-                                 VectorOfNamedValues,
-                                 ::std::size_t (*)(const ShapeHashKey&) > XShapeHash;
-
-        ::std::size_t refhasher( const ShapeHashKey& rKey )
-        {
-            // TODO(P2): Maybe a better hash function would be to
-            // spread mnParagraphIndex to 32 bit: a0b0c0d0e0... Hakmem
-            // should have a formula.
-            //
-            // Yes it has:
-            // x = (x & 0x0000FF00) << 8) | (x >> 8) & 0x0000FF00 | x
& 0xFF0000FF;
-            // x = (x & 0x00F000F0) << 4) | (x >> 4) & 0x00F000F0 | x
& 0xF00FF00F;
-            // x = (x & 0x0C0C0C0C) << 2) | (x >> 2) & 0x0C0C0C0C | x
& 0xC3C3C3C3;
-            // x = (x & 0x22222222) << 1) | (x >> 1) & 0x22222222 | x
& 0x99999999;
-            // 
-            // Costs about 17 cycles on a RISC machine with infinite
-            // instruction level parallelism (~42 basic
-            // instructions). Thus I truly doubt this pays off...
-            return reinterpret_cast< ::std::size_t >(rKey.mxRef.get()) ^ (rKey.mnParagraphIndex
<< 16L);
-        }
+        // A hash functor for ShapeHashKey objects
+        struct ShapeKeyHasher {
+		::std::size_t operator()( const ShapeHashKey& rKey ) const
+		{
+		// TODO(P2): Maybe a better hash function would be to
+		// spread mnParagraphIndex to 32 bit: a0b0c0d0e0... Hakmem
+		// should have a formula.
+		//
+		// Yes it has:
+		// x = (x & 0x0000FF00) << 8) | (x >> 8) & 0x0000FF00 | x & 0xFF0000FF;
+		// x = (x & 0x00F000F0) << 4) | (x >> 4) & 0x00F000F0 | x & 0xF00FF00F;
+		// x = (x & 0x0C0C0C0C) << 2) | (x >> 2) & 0x0C0C0C0C | x & 0xC3C3C3C3;
+		// x = (x & 0x22222222) << 1) | (x >> 1) & 0x22222222 | x & 0x99999999;
+		// 
+		// Costs about 17 cycles on a RISC machine with infinite
+		// instruction level parallelism (~42 basic
+		// instructions). Thus I truly doubt this pays off...
+		return reinterpret_cast< ::std::size_t >(rKey.mxRef.get()) ^ (rKey.mnParagraphIndex
<< 16L);
+	    }
+	};
 
+        // A hash map which maps a XShape to the corresponding vector of initial properties
+        typedef ::std::hash_map< ShapeHashKey, VectorOfNamedValues, ShapeKeyHasher >
XShapeHash;
 
         class NodeFunctor
         {
@@ -430,8 +430,7 @@ namespace animcore
 
         // scan all nodes for visibility changes, and record first
         // 'visibility=true' for each shape
-        XShapeHash aShapeHash( 101, 
-                               &refhasher );
+        XShapeHash aShapeHash( 101 );
  
         NodeFunctor aFunctor( aShapeHash );
 



Mime
View raw message