Browse Source

Spread bitmap store hash table elements

XOR of two sequential ints makes for an inefficient hash table.  The
hash_combine function is intended for this purpose
7.0
Seth Hillbrand 3 years ago
parent
commit
ed02d7c974
  1. 6
      common/bitmap_store.cpp

6
common/bitmap_store.cpp

@ -28,6 +28,7 @@
#include <bitmaps.h>
#include <bitmap_store.h>
#include <bitmaps/bitmap_info.h>
#include <hash_eda.h>
#include <kiplatform/ui.h>
#include <paths.h>
#include <pgm_base.h>
@ -93,7 +94,10 @@ static const wxString IMAGE_ARCHIVE = wxT( "images.tar.gz" );
size_t std::hash<std::pair<BITMAPS, int>>::operator()( const std::pair<BITMAPS, int>& aPair ) const
{
return std::hash<int>()( static_cast<int>( aPair.first ) ^ std::hash<int>()( aPair.second ) );
std::size_t seed = 0xa82de1c0;
hash_combine( seed, static_cast<size_t>( aPair.first ), static_cast<size_t>( aPair.second ) );
return seed;
}

Loading…
Cancel
Save