In an earlier post I whined about the speed of the syntax highlighting algorithm I was using. In looking closer, it appears that the RichEdit control is perhaps the real culprit. I've seen hints about this before, but only this morning ran a speed test to get more details.
Within the syntax highlighting loop, the following code is used to set the color of selected text in a RichEdit control. It's part of the original code legacy from Borje.
This code takes up 80% of the time in the syntax highlighting loop!
The actual code to separate out the keywords/comments/quotes in a large snippet was 0.7 seconds (20%) out of a total 3.9 seconds - still not instantaneous, but much less of the problem that I might have expected.
So, the question is, does anyone have a suggestion on how to significantly speed up this code?
Within the syntax highlighting loop, the following code is used to set the color of selected text in a RichEdit control. It's part of the original code legacy from Borje.
This code takes up 80% of the time in the syntax highlighting loop!
The actual code to separate out the keywords/comments/quotes in a large snippet was 0.7 seconds (20%) out of a total 3.9 seconds - still not instantaneous, but much less of the problem that I might have expected.
So, the question is, does anyone have a suggestion on how to significantly speed up this code?
Code:
Function setRichTextColor( ByVal NewColor As Long) As Long Local cf As CHARFORMAT cf.cbSize = Len(cf) 'Length of structure cf.dwMask = %CFM_COLOR 'Set mask to colors only cf.crTextColor = NewColor 'Set the new color value SendMessage(hRichEdit, %EM_SETCHARFORMAT, %SCF_SELECTION, VarPtr(cf)) End Function
Comment