vmg / sundown

Standards compliant, fast, secure markdown processing library in C
1.99k stars 385 forks source link

2x speedup when autolink extension is used #26

Closed kjk closed 13 years ago

kjk commented 13 years ago

I didn't come up with this change, but it's been done by another guy who ported upskirt to Go. In Go it gives 2x speedup and since it's literal translation of C code, it should give the same speedup in C and be trivial to port.

The basic idea is that instead of triggering char_autolink() test on characters that are frequent in regular text ('h', 'f', 'm'), it's only triggered on much less frequent ':' and char_autolink() logic is modified accordingly.

Here's how it looks in my Go port: https://github.com/kjk/go-markup/commit/b760fe6f79d95e67cec08ecf1f2c840e86b4fce2 based on the original change: https://github.com/russross/blackfriday/commit/679e1686dbcb2f48866df1c2cc0ac64bc6048af7

vmg commented 13 years ago

Hey man,

thanks a lot for the heads up. I've rewritten most of the autolinking code with this design in mind -- it now supports email addresses and links without the http prefix: it's both faster and more complete.

Please shout if you find any issues with autolinking.

Cheers, Vicent Marti

On Thu, Jun 2, 2011 at 1:08 AM, kjk reply@reply.github.com wrote:

I didn't come up with this change, but it's been done by another guy who ported upskirt to Go. In Go it gives 2x speedup and since it's literal translation of C code, it should give the same speedup in C and be trivial to port.

The basic idea is that instead of triggering char_autolink() test on characters that are frequent in regular text ('h', 'f', 'm'), it's only triggered on much less frequent ':' and char_autolink() logic is modified accordingly.

Here's how it looks in my Go port: https://github.com/kjk/go-markup/commit/b760fe6f79d95e67cec08ecf1f2c840e86b4fce2 based on the original change: https://github.com/russross/blackfriday/commit/679e1686dbcb2f48866df1c2cc0ac64bc6048af7

Reply to this email directly or view it on GitHub: https://github.com/tanoku/upskirt/issues/26