-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Use WeakMap if available to avoid O(n) lookup #62
base: master
Are you sure you want to change the base?
Conversation
Do you want to extract this to an npm module? Inspired by your previous PR I implemented something similar here because I need it in that project too. Ideally I’d prefer this be an external module I could depend on in both projects. |
Isn't https://github.com/medikoo/es6-weak-map exactly what you're looking for? |
var WeakMap;
if (useWeakMap) {
WeakMap = require('es6-weak-map');
} else {
WeakMap = require('es6-weak-map/polyfill');
} |
I don’t really care that much about real
|
Do you wish to restrict input values to only objects? (just like WeakMap) |
Yeah, so that WeakMap case works. |
I think https://github.com/WebReflection/es6-collections implementation should suit you except:
I could fix both and extract code to the new module. OK? |
I’d really prefer my implementation in this case. The surface area I need is very small, and putting components into “slots” by their displayName/name reduces the lookup time for the common case. I think we can benefit from having a very specific use case (map by component) here. |
OK, I think I have full picture. I'll try to come up with something soon. |
Have you come up with something new? Or should we just close this? |
5f79811
to
6b0da8c
Compare
@wkwiatek Thanks for reminding.. I've created https://github.com/sheerun/component-map and update this PR to use it. ComponentMap includes lots of tests that also verify proper garbage collection. Hope you like it. |
@gaearon You might want to consider using component-map it in react-hot-loader as well |
Supersedes #57