Another WeakMap implementation

44 views
Skip to first unread message

crb...@gmail.com

unread,
Sep 29, 2013, 6:51:59 AM9/29/13
to polym...@googlegroups.com
Hi guys.
I'm using a Polymer polyfills on some projects, and now had to use a WeakMap now.
I had to link to some frozen objects, so I had to rewrite it fully without relying on object properties.(I also wrote some methods for original WeakMap to fully comply the spec)

1e7 elements benchmark shows similar results and if returning simple object instead of 

var mapObject = {};
Object.defineProperties(mapObject, {...});
return Object.freeze(mapObject);

chrome shows up to 3 times speeding up in comparison with original one.
Why does it happen is still a mystery for me, but however, guys, I would be glad if my solution will get into Polymer.
Here's a repo:
'fast-weakmap' is modified yours(i've expected that it will be really faster up to 5 times or so)
'good-weakmap' is my one(under good I mean "complying with ES6 and not creating attributes")

Erik Arvidsson

unread,
Sep 29, 2013, 12:22:52 PM9/29/13
to crb...@gmail.com, polym...@googlegroups.com
The good-weakmap.js is O(n) which is not acceptable for us. It really needs to be O(1).

We are well aware that the WeakMap in Polymer is far from correct but it is a sufficiently correct subset for our needs and it was also optimized looking at non micro benchmarks.


Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
erik


Reply all
Reply to author
Forward
0 new messages