Skip to content
This repository has been archived by the owner on Mar 12, 2018. It is now read-only.

classes: Dedupe all classes #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

classes: Dedupe all classes #25

wants to merge 1 commit into from

Conversation

TimothyGu
Copy link
Member

This causes a slow down especially on cases with simple string-only arrays (~3×), but this is the best I can do. Optimization welcome.

@alubbe
Copy link
Member

alubbe commented Jan 13, 2016

For escapeAlways, couldn't we just check equality to true?

In terms of performance, I ran some benchmarks and the only to speed it up
would to be to use ES6 Sets instead of objects. We could feature detect
them, node has them, more and more browsers have them and we could fall
back to objects.
Am 13.01.2016 4:30 vorm. schrieb "Timothy Gu" [email protected]:

This causes a slow down especially on cases with simple string-only arrays

(~3×), but this is the best I can do. Optimization welcome.

You can view, comment on, or merge this pull request online at:

#25
Commit Summary

  • classes: Dedupe all classes

File Changes

Patch Links:


Reply to this email directly or view it on GitHub
#25.

@ForbesLindesay
Copy link
Member

One option would be to enable only in dev-mode and throw errors rather than deduping?

@TimothyGu
Copy link
Member Author

One option would be to enable only in dev-mode and throw errors rather than deduping?

Err… I don't see the point in that. Throwing errors prevents a perfectly okay use-case that allows more flexibility. Plus, to throw errors we have to first check for dups, so no performance gains can be reaped from this approach either.

@TimothyGu
Copy link
Member Author

In terms of performance, I ran some benchmarks and the only to speed it up would to be to use ES6 Sets instead of objects.

I did benchmark Sets but it was done on an older, slower version of the patch that didn't share the output object, so no performance gains were achieved. I'll test some more.

This causes a slow down especially on cases with simple string-only
arrays, but this is the best I can do. Optimization welcome.
@TimothyGu
Copy link
Member Author

Nah, Set is still a lot slower. I also added another optimization that prevents a branch out = out || {}.

For escapeAlways, couldn't we just check equality to true?

Derp. Fixed.

@ForbesLindesay
Copy link
Member

The advantage of throwing on dupes is that we could do all the deduping inside if (process.env.NODE_ENV !== 'production'), which would mean no performance penalty in production.

I'm not saying it's the best thing to do, just that it's an option.

@alubbe
Copy link
Member

alubbe commented Jan 14, 2016

That's a good point - do we actually want to check for dupes? It is valid html to print classes more than once and we do take a hit for these extra checks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants