On Wed, Sep 08, 2021 at 06:08:53PM +0200, Claudio Jeker wrote: > On Wed, Sep 08, 2021 at 05:40:31PM +0200, Theo Buehler wrote: > > On Wed, Sep 08, 2021 at 03:05:41PM +0200, Claudio Jeker wrote: > > > Looking at profiling information and the code made me realize that these > > > recallocarray calls growing the array by one every time are unnecessary. > > > The size of the array is known in advance so use that information and > > > build it up ahead of time. > > > > > > In the roa case the IP list is double nested and so one still needs to > > > resize the array but for mft the file-and-hash list is only defined once > > > per MFT and so calloc can be used there. > > > > > > Works for me, the speed-up is not really noticable but I think this change > > > is still worth it. > > > > I'm ok with this. > > > > Should we assert after the for loops that we added as many filehashes or > > addresses as allocated? This is currently more obvious than after this > > change. > > Hmm. The code is correct even if it loads less elements. It will > overallocate but with NULL. Also currently the code fails hard if an > element does not parse. So not sure about that.
I agree with all of that, it was just a suggestion. I'm ok with your diff as it is.