@@ -335,6 +335,26 @@ int main( int argc, char** argv )
335335
336336 printf ( " \n " );
337337
338+ TracyMessageL ( " Caching unpacked message id to message index mapping" );
339+ std::vector<robin_hood::unordered_flat_map<std::string, uint32_t >> msgdata;
340+ msgdata.resize ( arch.size () );
341+ for ( size_t i=0 ; i<arch.size (); i++ )
342+ {
343+ printf ( " %zu/%zu\r " , i+1 , arch.size () );
344+ fflush ( stdout );
345+ auto & map = msgdata[i];
346+ auto num = arch[i]->NumberOfMessages ();
347+ map.reserve ( num );
348+ for ( size_t j=0 ; j<num; j++ )
349+ {
350+ char unpacked[2048 ];
351+ auto packed = arch[i]->GetMessageId ( j );
352+ auto size = arch[i]->UnpackMsgId ( packed, unpacked );
353+ map[std::string ( unpacked, size )] = j;
354+ }
355+ }
356+ printf ( " \n " );
357+
338358 TracyMessageL ( " Calculating message groups and indirect references" );
339359 struct IndirectData
340360 {
@@ -364,19 +384,21 @@ int main( int argc, char** argv )
364384 ExpandingBuffer eb;
365385 for ( int i=0 ; i<unique; i++ )
366386 {
367- if ( ( i & 0x3FF ) == 0 )
387+ if ( ( i & 0x3FFF ) == 0 )
368388 {
369389 printf ( " %i/%zu\r " , i, unique );
370390 fflush ( stdout );
371391 }
372392
393+ char unpk[2048 ];
394+ auto unsz = compress->Unpack ( msgidvec[i], unpk );
395+ auto unstr = std::string ( unpk, unsz );
396+
373397 groups.clear ();
374398 for ( int j=0 ; j<arch.size (); j++ )
375399 {
376- uint8_t repack[2048 ];
377- arch[j]->RepackMsgId ( msgidvec[i], repack, *compress );
378- const auto idx = arch[j]->GetMessageIndex ( repack );
379- if ( idx != -1 )
400+ auto it = msgdata[j].find ( unstr );
401+ if ( it != msgdata[j].end () )
380402 {
381403 groups.emplace_back ( j );
382404 }
0 commit comments