-
-
Notifications
You must be signed in to change notification settings - Fork 661
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add haxe.runtime.Copy #11863
Add haxe.runtime.Copy #11863
Conversation
I'm excited for this new addition, although I noticed that |
The reason is mostly that I copied this from Nicolas. And yes we should definitely change it to |
There are two situations related to
function main() {
var obj1 = {};
var obj1Copy = haxe.Copy.copy(obj1);
trace(obj1); // { __id__: 0 }
trace(obj1Copy); // {}
} We could look into removing these values after copying, but I don't know if that would actually improve anything. Ultimately this happens for any implementation that uses Edit: I've changed it to not use |
I took another look at the enum parameter handling of the original implementation and decided to forego it. It was implemented for neko, php and js and as it turns out, it actually wasn't working on JS unless This means that the copy implementation will also run into what I outlined in #11865. This isn't ideal, but it's also not fatal because enum values cannot be recursive by themselves, and so at worst they end up appearing as multiple instances. Edit: This is now addressed by deferring all recursions. This ensures the enum value instance is cached before anyone else can come across it again. |
This should be fine now. I'm sure it can be optimized more but it's a good start. The remaining question is where to actually put this. Having |
I've created the |
From #11857.
Needs more tests and such.
Closes #11862.