Re: New function's UpperCase / LowerCase



Hi Lars,

Before testing, a couple of suggestions:-

The line:-

pResult := PChar(Result);

performs an unnecessary call of the @LStrToPChar function. This could be
replaced by:-

pResult := pointer(Result);


The line:-

if (S[CharNo+a] >= 'a') and (S[CharNo+a] <= 'z') then

uses 2 conditional jumps. Using

if (S[CharNo+a] in ['a'..'z']) then

instead, only uses 1 condition jump.


--
regards,
John

The Fastcode Project:
http://www.fastcodeproject.org/


"Lars G" <lbg-at-aplusmail-dot-dk> wrote in message
news:456b3e88$1@xxxxxxxxxxxxxxxxxxxxxxxxx
Hi

function UpperCase_LBG_Pas_1_a(const S: string): string;
const a=1;
var
Max, CharNo : Cardinal;
pResult : PChar;
begin
Max := Length(S);
SetLength(Result, Max);
if Max <= 0 then exit;
pResult := PChar(Result);
CharNo := 0;
repeat
pResult[CharNo] := S[CharNo+a];
if (S[CharNo+a] >= 'a') and (S[CharNo+a] <= 'z') then
pResult[CharNo] := char(Ord(S[CharNo+a]) - 32);
Inc(CharNo);
until(CharNo >= Max);
end;


.



Relevant Pages