Should not create a new object if the values are the same
See original GitHub issueI’m not sure if this is a bug or if I’m misunderstanding how this is supposed to work.
I assumed in the following example one
and two
would be the same object.
const obj = { foo: 0 };
const one = immutable(obj).set('foo', 'bar').value();
// { foo: 'bar' };
const two = immutable(one).set('foo', 'bar').value();
// { foo: 'bar' };
one === two
// false
Issue Analytics
- State:
- Created 6 years ago
- Reactions:2
- Comments:7 (4 by maintainers)
Top Results From Across the Web
python - How to avoid creating objects with same values?
Your current code well prevents different objects with same value from being created, but you can't stop an object from having two references. ......
Read more >Creating Objects
When you create an object, you are creating an instance of a class, therefore "instantiating" a class. The new operator requires a single,...
Read more >Objects - Definition & Usage - AutoHotkey
When an object reference is compared with some other value using = , == , != or <> , they are considered equal...
Read more >Creating Objects - Learning the Java Language
Simply declaring a reference variable does not create an object. For that, you need to use the new operator, as described in the...
Read more >Create Duplicate Object (CRTDUPOBJ) - IBM
It does not create an exact duplicate of files. The new object must be renamed if it is created in the library that...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks for the more detailed description. I get it now and it makes sense. We’ll track this as an enhancement as it’s going to change the current behaviour of a few methods. Thanks for reporting Luke.
Was looking through the code and came to the conclusion that it is non-trivial at least for someone not comfortable with the code base. The problem is that the code works top-down and clones all objects along the path, but only at the very end inside
changeCallback
do we know if that was actually needed. At this point we could return the original thing, but still wasted time on all the cloning.So how do we peek at the bottom to see if it would be a noop without duplicating most of the walking-logic? Or how do we delay/schedule the cloning until that point?