Menu

#22 Unicode Version speedup

open
nobody
None
5
2006-10-16
2006-10-16
PyScripter
No

In Synedit.pas the Ceil function is used in four
different places e.g. in TCustomSynEdit.ExpandAtWideGlyphs:

CountOfAvgGlyphs := Ceil(fTextDrawer.TextWidth(S[i])/
fCharWidth);

This function is very slow and coded suboptimally in
Delphi.

Patch:

Introduce a new function:

function CeilOfIntDiv(Dividend: Cardinal; Divisor:
Word): Word;
Var
Remainder: Word;
begin
DivMod(Dividend, Divisor, Result, Remainder);
if Remainder > 0 then
Inc(Result);
end;

and replace the calls to Ceil with calls to the above
function. The example above becomes:

CountOfAvgGlyphs :=
CeilOfIntDiv(fTextDrawer.TextWidth(S[i]), fCharWidth);

Discussion


Log in to post a comment.