I’ve been thinking through the use of hashmaps to store some large data chunks and I wanted to think through how the data is stored and how the cycle usage is calculated.
Say I have a HashMap<Nat, Buffer>. When I .get a buffer out of the map, what is happening? Since Buffers are an object like entity, am I just getting a Ref to an existing object? If I manipulate the Buffer do I have to .put it back? I know if it were an array, I’d have to put back a different array that I’d create with the mutations I want. But I’m not sure about buffer.
If the .get has to create a new copy of the buffer in the HashMap, how expensive is this? Is it just a memcopy? And is that expensive?
If I have to .put the changed buffer back into the hash map, am I making an even newer copy? And is that expensive?
If I’m having to get and put back a bunch of copies with HashMap, would it make more sense to just have an Initialized array of a bunch of Buffers that I can use without having to reinstantiate a bunch of buffers in and out of HashMaps?
Perhaps .get does get a ref to the existing object in orthogonal memory and I’m all good and no .put is necessary. I guess an experiment is warranted, but I thought I’d ask first in case anyone had a clear answer.