Wsm2110 / Faster.Map

Faster.Map is a high-performance, thread-safe key-value store designed to outperform the standard Dictionary and ConcurrentDictionary
MIT License
75 stars 7 forks source link

Suggestion about Resize() #15

Closed miroslavp closed 1 year ago

miroslavp commented 1 year ago

I have a suggestion for the code bellow in the Resize() method: https://github.com/Wsm2110/Faster.Map/blob/883c9fe55030bb0be7cd90e166ee7d2c6e931924/src/DenseMapSIMD.cs#L758-L762 It can be simplified to

var oldEntries = _entries.Clone();
var oldMetadata = _metadata.Clone();

It looks simpler and is slightly faster. I tried it with array of 1_000_000 ints and it was about 30% faster. Both the Array.Copy and Array.Clone make shallow copy.

Wsm2110 commented 1 year ago

Thnx, didn`t know that :)