evilstreak / markdown-js

A Markdown parser for javascript
7.69k stars 863 forks source link

Replace `count_lines` with faster implementation #146

Closed eviltrout closed 10 years ago

eviltrout commented 10 years ago

This patch replaces count_lines with a faster implementation.

current method:

console.time('count_lines'); for (i=0; i<100000; i++) { count_lines(longString) }; console.timeEnd('count_lines')
count_lines: 221.655ms

new version:

console.time('count_lines'); for (i=0; i<100000; i++) { count_lines(longString) }; console.timeEnd('count_lines')
count_lines: 114.764ms
ashb commented 10 years ago

Was this actually showing up in any benchmarks or just 'could be made faster and clearer so we did'?

eviltrout commented 10 years ago

No benchmarks, I was just looking through some code and saw it and thought, hey I can do this using split, let's see if it's faster, and it was :)