Replies: 3 comments 7 replies
-
We can consider a PR for |
Beta Was this translation helpful? Give feedback.
-
My 2 cents on this as I'm the one who implemented Although, I agree that the implementation is not very "efficient" at first glance. I believe that it covers 99% of use cases. There are cases where you might notice a performance issue of course, for example:
const map = proxyMap();
// this will take around ~150ms
console.time("add 1000 to map");
for (let i = 0; i < 1000; i++) {
map.set(i, { value: i, somehtingElse: `hello${i}` });
}
console.timeEnd("add 1000 to map");
// ~2ms
console.time("add 100 to map");
for (let i = 0; i < 100; i++) {
map.set(i, { value: i, somehtingElse: `hello${i}` });
}
console.timeEnd("add 100 to map"); For everything below 100, we are talking about microseconds, hence it should cover 99% of use cases. |
Beta Was this translation helpful? Give feedback.
-
@fkhadra is |
Beta Was this translation helpful? Give feedback.
-
Hi,
I've been wanting to use proxyMap and proxySet for a while but I've always been put off because the implementations aren't very efficient. Maps and Sets have particular performance characteristics and are often chosen for those reasons, and the valtio implementation doesn't keep those characteristics due to performing many linear lookups for things.
Is there a particular reason those performance characteristics aren't maintained? I think it would require a fair amount of synchronizing data between the data arrays and a parallel structure, but I think it would be possible. It looks like the data lists are almost just a way to signal that things have changed inside the data structure.
Is this something that has been considered and rejected? If not, how would you feel about a PR that attempts to do this?
Beta Was this translation helpful? Give feedback.
All reactions