The home-grown CSS parser is now 30 times faster!

The CSS parser for LIVEditor

I always want to make my LIVEditor text editor runs and responds to user’s actions as fast as possible.

As you might have guessed, LIVEditor contains a CSS parser whose most important job is to tell which and where the css selectors and css attributes are defined in the input .css file.

The CSS parsing speed

The the css parser is home-grown and it does its job pretty well, but I was not satisfied with its speed.

so today I’ve spent several hours investigating it again and tried to improve it’s parsing performance.

 And the result is quite good –  now it takes only around 30 to 50 millisecond to parse the 97-KB bootstrap.css file on my I5 CPU depends on the current CPU-load.

Threaded CSS parsing

As far as UI response time is concerned, the speed is very good, especially when the parsing is delegated to another thread so it doesn’t block the man UI thread.