Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-07

Synedits TokenAccu, uing move()

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin Friebe

In Synedit's PaintLines is a functioin called AddHighlightToken.

At one point it copies the current token to the end of the TokenAccu. At this point a remark can be found:

    // Don't use AppendStr because it's more expensive.
Instead of using AppendStr, it implements a plain "for i := 0 to ..."
loop, copying the content byte by byte.

I am pretty sure (but would like to have that confirmed) that using "move" would be even faster?
yes I could set up a test and profile it, but maybe someone already knows how move performs vs for loops ?

Thanks in advance
Martin

Reply by email

Mattias Gaertner
to Martin Friebe
Show quoted text 8 lines
In Synedit's PaintLines is a functioin called AddHighlightToken. At one point it copies the current token to the end of the TokenAccu. At this point a remark can be found: // Don't use AppendStr because it's more expensive. Instead of using AppendStr, it implements a plain "for i := 0 to ..." loop, copying the content byte by byte.

A simple for loop of a few iterations is always faster than a procedure call. And afaik AppendStr created a lot more overhead.

I am pretty sure (but would like to have that confirmed) that using "move" would be even faster?

Some years ago Move was slower than loops with a few iterations. Unless Move is now inlined, this is still true.

yes I could set up a test and profile it, but maybe someone already knows how move performs vs for loops ?

Every theory is grey. Only a real test gives you a clue.

Mattias

Reply by email