diff options
author | Herbert Dürr <hdu@apache.org> | 2013-04-16 10:27:35 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2013-05-25 12:11:51 +0100 |
commit | 0cc228354f7015ee1e6c0d376c117fbf04f58a5f (patch) | |
tree | 2e22508a13a7c579c6e12c44ea2c8b7e07ef76aa /animations/source | |
parent | Revert "Fix improper glyph positioning with old fonts" (diff) | |
download | core-0cc228354f7015ee1e6c0d376c117fbf04f58a5f.tar.gz core-0cc228354f7015ee1e6c0d376c117fbf04f58a5f.zip |
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.
(cherry picked from commit fb8df93381493dee3d0e511c556d82d1f177367a)
Conflicts:
animations/source/animcore/targetpropertiescreator.cxx
Change-Id: I51ae91ef74002cbc8f24cd5f4df7dda58e1c4f8d
Diffstat (limited to 'animations/source')
-rw-r--r-- | animations/source/animcore/targetpropertiescreator.cxx | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/animations/source/animcore/targetpropertiescreator.cxx b/animations/source/animcore/targetpropertiescreator.cxx index d42799f4fc3e..c583e137d6bb 100644 --- a/animations/source/animcore/targetpropertiescreator.cxx +++ b/animations/source/animcore/targetpropertiescreator.cxx @@ -139,28 +139,30 @@ namespace animcore } }; - // A hash map which maps a XShape to the corresponding vector of initial properties - typedef ::boost::unordered_map< ShapeHashKey, - VectorOfNamedValues, - ::std::size_t (*)(const ShapeHashKey&) > XShapeHash; - - ::std::size_t refhasher( const ShapeHashKey& rKey ) + // A hash functor for ShapeHashKey objects + struct ShapeKeyHasher { - // 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); - } + ::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 ::boost::unordered_map< ShapeHashKey, VectorOfNamedValues, ShapeKeyHasher > XShapeHash; class NodeFunctor @@ -419,8 +421,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 ); |