Skip to content

Add memoisation of functions#7

Merged
developit merged 2 commits intodevelopit:masterfrom
sgrowe:memoisation
Sep 2, 2017
Merged

Add memoisation of functions#7
developit merged 2 commits intodevelopit:masterfrom
sgrowe:memoisation

Conversation

@sgrowe
Copy link

@sgrowe sgrowe commented Aug 11, 2017

This module isn't that helpful without it! 😄

Resolves issue #4

return function(e) {
const cache = component._linkedStates || (component._linkedStates = {});

return cache[`${key}\n${eventPath}`] || (cache[`${key}\n${eventPath}`] = function(e) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not make ${key}\n${eventPath} to be a variable?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good suggestion and I normally would do that in my own code but in this case it increases the gzipped file size from 315 bytes to 317 bytes. I guess that's a pretty inconsequential difference but as the philosophy of preact is "as small a file size as possible" I thought that maybe the smaller file size would be preferable. What do you think?

@developit developit merged commit 0314902 into developit:master Sep 2, 2017
developit added a commit that referenced this pull request Sep 2, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants