@@ -6307,38 +6307,38 @@ threadsafe Function/WAVE GetCacheKeyHashMap()
63076307 return wv
63086308 endif
63096309
6310- WAVE wv = HM_Create ( size = 2^14, valueType = IGOR_TYPE_32 BIT_INT | IGOR_TYPE_UNSIGNED)
6311-
63126310 WAVE /Z/ T/ SDFR= dfr keys
6313- if ( WaveExists ( keys))
6314- FillHashMapFromNoteIndexVector ( wv, keys)
6315- HM_RehashIfRequired ( wv)
6316- KillOrMoveToTrash ( wv = keys)
6317- endif
6311+ WAVE wv = GetHashMapFromNoteIndexVector ( keys, IGOR_TYPE_32 BIT_INT | IGOR_TYPE_UNSIGNED)
6312+ KillOrMoveToTrash ( wv = keys)
63186313
63196314 MoveWave wv, dfr: hashmap
63206315
63216316 return wv
63226317End
63236318
6324- /// @brief Fill the hashmap with the wave entries as keys and their index as values
6319+ /// @brief Return a hashmap with the wave entries as keys and their index as values
63256320///
63266321/// Ignores empty values
6327- threadsafe static Function FillHashMapFromNoteIndexVector ( WAVE /WAVE hashmap, WAVE /T entries)
6322+ threadsafe static Function/WAVE GetHashMapFromNoteIndexVector ( WAVE /Z / T entries, variable valueType )
63286323
63296324 variable numEntries
6325+ variable size = 2^14
6326+
6327+ numEntries = WaveExists ( entries) ? GetNumberFromWaveNote ( entries, NOTE_INDEX) : 0
6328+ ASSERT_TS ( IsFinite ( numEntries) , "the wave entries exists but does not hold a NOTE_INDEX" )
63306329
6331- numEntries = GetNumberFromWaveNote ( entries , NOTE_INDEX )
6332- ASSERT_TS ( IsFinite ( numEntries ) , "entries does not hold a NOTE_INDEX" )
6330+ size = max ( size , HM_CalculateOptimumSize ( numEntries ) )
6331+ WAVE hashmap = HM_Create ( size = size , valueType = valueType )
63336332
63346333 if ( numEntries == 0 )
6335- // nothing to do
6336- return NaN
6334+ return hashmap
63376335 endif
63386336
63396337 Make / N= ( numEntries) / FREE indexHelper
63406338
63416339 indexHelper[] = ( strlen ( entries[ p]) > 0 ) ? HM_AddEntry ( hashmap, entries[ p] , var = p) : 0
6340+
6341+ return hashmap
63426342End
63436343
63446344/// @brief Return the wave reference wave holding the cache stats
0 commit comments