[Lazarus] About 0013268: SynEdit parses every line twice on load or paste (Attn: Flávio)
Martin Friebe
lazarus at mfriebe.de
Thu Mar 5 12:28:41 CET 2009
Flávio Etrusco wrote:
>>> *If* BeginUpdate works, then the content of my original mail should be
>>> applicable
>> To avoid any misunderstanding:
>>
>> *If* / *Once* BeginUpdate works, then you can insert a batch of say 100
>> lines (with Lines.Add or Lines.Insert). It will scan 101 lines (because
>> yes, 1 line needs to be rescanned)
>> I do not think we need to worry about the performance between 100 or 101
>> Lines? (Not saying this may not be "fixed", but it would have a very low
>> priority "post 1.2")
>>
>> If you insert a single line, it will scan 2 Lines. True that is not good
>> neither. But it will still be so fast that no human can tell the difference.
>>
>> So I will fix BeginUpdate, *if* it is broken (and I will try to get that
>> done for 0.9.28)
>>
>> But making the changes according to the original description will be
>> deferred for later (unless a nice clean patch comes along).
>> It may also be that it will become unnecessary due to other changes that
>> may be made in future.
>>
>>
>> Do you think fixing BeginUpdate will improve the Situation enough for now?
>>
>> Best Regards
>> Martin
>>
>
> IMO this is pretty good enough, yes. (Not sure it's possible, though)
> The important thing is to fix the paste performance; I didn't mean to
> be pedantic with the code ;-)
>
>
No problem, it is always good to sort out any doubt.
From your description your problem may be something different though....
Do you refer to paste, as done by SynEdit internally (not by externally
calling lines.Insert) ?
Because the current paste (if you press ctrl-v in the IDE, having 10
lines in the Clipboard) isn't affected by this bug. (I looked at it in
the debugger)
It is affected by 2 other things:
1) A bug, that paste insert 10 empty lines, sans 10 empty lines, puts
the content in, scans the content.
- The 10 lines Content a scanned in a single call to ScanFrom => so
ScanFrom needs only once to rescan a single known line, and then does 10
lines without any duplication scanning.
- The same applies to scanning the 10 empty lines. It is *one* extra
call to ScanFrom (which should be avoided)
2) A problem in the design of SynEdit's Ranges
If the code you insert has unbalanced keyword pairs (begin without end /
"(*" without "*)" / sometimes normal "(" without ")" / .... ) then each
call to ScanFrom (the good one, that scans the content) will always Scan
to the very end of file!!!
This is because The Ranges, contain info how many open "begins" there
are. If that info changes, then all Ranges to the end of File must be
updated (Folding needs this info, too)
I do have ideas on how I may be able to improve that, so I haven't
verified they will work as expected. => and it will be a lot of work to
fix this kind of thing. So that is definitely an item for "post 1.2"
The best way to experience is MacOSAll.pp ( in the FPC source dir
packages\univint\src\MacOSAll.pas)
and type on the top of file (outside any comment of course) "begin" (not
the time it takes for the "n") :( :( :(
The only good news in this is, that I believe the it can be partly
improved by refactoring the highlighter itself => I think I can
implement a faster Scanning.
Best Regards
Martin
More information about the Lazarus
mailing list