Skip to content
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

improved speed of jade.escape() #1976

Merged
merged 1 commit into from
Jun 9, 2015
Merged

Conversation

alubbe
Copy link
Member

@alubbe alubbe commented Jun 2, 2015

see #1975

@alubbe alubbe mentioned this pull request Jun 2, 2015
5 tasks
, '"': '"'
}
, _MATCH_HTML = /[&<>"]/g;

Copy link
Member

Choose a reason for hiding this comment

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

These constants don't need the preceding _

@ForbesLindesay
Copy link
Member

Looks good. It will also need to be added to the jade-runtime module for 2.0.0

@TimothyGu
Copy link
Member

LGTM.

Note that sometimes the performance of these escape functions can vary a lot from how you call them. For example, a while ago while tuning ejs I found out that this one you used fares a lot better on client mode (IIRC), while the original is better when you are just compiling and executing in the same environment. That's something to keep in mind when making performance changes.

You should also check if aliasing the variables in the .replace() callback and/or escape() would help.

@alubbe
Copy link
Member Author

alubbe commented Jun 2, 2015

@TimothyGu I use both jsperf for the stuff that comes out of the client compilation as well as the server-side benchmark that I forked from yours - so far, I see much better performance in both scenarios and no performance regressions. Do you have a specific benchmark I should look at?
Could you also help me out in better understanding what you mean by aliasing the variables?

@alubbe
Copy link
Member Author

alubbe commented Jun 6, 2015

@ForbesLindesay is the jade runtime already extracted into its own repo? The one in this org seems to be a little outdated.

@ForbesLindesay
Copy link
Member

https://github.com/jadejs/jade-runtime is the 2.0.0 runtime. It is ahead of 1.0.0 runtime in a few key areas. If it's behind in anything then that's most likely a mistake.

ForbesLindesay added a commit that referenced this pull request Jun 9, 2015
improved speed of jade.escape()
@ForbesLindesay ForbesLindesay merged commit 2194cbb into pugjs:master Jun 9, 2015
@alubbe alubbe deleted the fasterescape branch June 9, 2015 09:55
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.

None yet

3 participants