Open WhyNotHugo opened 1 year ago
Whenever data is read via
load
orread
, the dataIni
instance is mutated in place, but a clone of the inner data is returned too. So I end up with two copies of the data.Why return a clone of the data?
HashMap
'sClone
implementation is recursive, so this ends up copying the entire structure. Am I missing something here?Is it somehow possible to do something like
Init::read
, but only get one copy of the data in memory? I don't need two copies. I know that I can just drop the clone, but I don't see the point it copying data just to drop it.
This is intentional (to some extent), basically some implementations are intended to mutate in-place and others are meant to return, so it provides the best of both worlds at the cost of using more memory. If you wanted, you could simply not assign it and the compiler would know to discard the return value. In all cases, the internal impl will need to store a hashmap. In the future however, it might be beneficial to do load_inplace()
/ read_inplace()
-esque functions.
Whenever data is read via
load
orread
, the dataIni
instance is mutated in place, but a clone of the inner data is returned too. So I end up with two copies of the data.Why return a clone of the data?
HashMap
'sClone
implementation is recursive, so this ends up copying the entire structure. Am I missing something here?Is it somehow possible to do something like
Init::read
, but only get one copy of the data in memory? I don't need two copies. I know that I can just drop the clone, but I don't see the point it copying data just to drop it.