After the recent performance improvements to the analyzer I found that the next bottleneck was the regex syntax highlighter. You know, that's what paints your regular expression pretty colors.
The slowness has probably affected fewer than 1% of the Regex Hero population. I say that because it was only really perceivable when dealing with a regular expression over 2,000 characters long.
Nevertheless, I had an idea for how I can improve it. The slowness had nothing to do with parsing speed, and everything to do with how I was drawing the characters. I was dynamically adding characters in colored sections to a single text block to create the colored effect. This, as it turns out, is not optimal. So what I did is I created text blocks on top of eachother (one for each color), and then simply assign the appropriate text values to each one.
For example, the text blocks might be composed of...
test
( )
\d\w
+
And since they're all on top of eachother this is what you see...
test(\d\w)+
The effect is exactly the same as it was before, but this is at least 3 times faster.
The slowness has probably affected fewer than 1% of the Regex Hero population. I say that because it was only really perceivable when dealing with a regular expression over 2,000 characters long.
Nevertheless, I had an idea for how I can improve it. The slowness had nothing to do with parsing speed, and everything to do with how I was drawing the characters. I was dynamically adding characters in colored sections to a single text block to create the colored effect. This, as it turns out, is not optimal. So what I did is I created text blocks on top of eachother (one for each color), and then simply assign the appropriate text values to each one.
For example, the text blocks might be composed of...
test
( )
\d\w
+
And since they're all on top of eachother this is what you see...
test(\d\w)+
The effect is exactly the same as it was before, but this is at least 3 times faster.
Comments
Post a Comment