MCPcopy Create free account
hub / github.com/ImageEngine/cortex / murmurHashAppend

Method murmurHashAppend

src/IECore/PathMatcher.cpp:803–830  ·  view source on GitHub ↗

Our hash is complicated by the fact that PathMatcher::Iterator doesn't guarantee the order of visiting child nodes in its tree (because it sorts using InternedString addresses for the fastest possible match() implementation). We therefore have to use a stack to keep track of our traversal through the tree, and output all the children at each level only after sorting them alphabetically.

Source from the content-addressed store, hash-verified

801// our traversal through the tree, and output all the children at each
802// level only after sorting them alphabetically.
803void IECore::murmurHashAppend( IECore::MurmurHash &h, const IECore::PathMatcher &data )
804{
805 HashStack stack;
806 for( PathMatcher::RawIterator it = data.begin(), eIt = data.end(); it != eIt; ++it )
807 {
808 // The iterator is recursive, so we use a stack to keep
809 // track of where we are. Resize the stack to match our
810 // current depth. The required size has the +1 because
811 // we need a stack entry for the root item.
812 size_t requiredStackSize = it->size() + 1;
813 if( requiredStackSize > stack.size() )
814 {
815 // Going a level deeper.
816 stack.push( HashNodes() );
817 assert( stack.size() == requiredStackSize );
818 }
819 else if( requiredStackSize < stack.size() )
820 {
821 // Returning from recursion to the child nodes.
822 // Output the hashes for the children we visited
823 // and stored on the stack previously.
824 popHashNodes( stack, requiredStackSize, h );
825 }
826
827 stack.top().push_back( HashNode( it->size() ? it->back().c_str() : "", it.exactMatch() ) );
828 }
829 popHashNodes( stack, 0, h );
830}

Callers

nothing calls this directly

Calls 6

popHashNodesFunction · 0.85
HashNodeClass · 0.85
pushMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected