Re: New function's UpperCase / LowerCase
- From: "John O'Harrow" <john@xxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 27 Nov 2006 20:37:07 -0000
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;
.
- Follow-Ups:
- Re: New function's UpperCase / LowerCase
- From: Lars G
- Re: New function's UpperCase / LowerCase
- References:
- New function's UpperCase / LowerCase
- From: Lars G
- New function's UpperCase / LowerCase
- Prev by Date: Re: Fastcode CharPosRev B&V 0.6.2
- Next by Date: Re: New function's UpperCase / LowerCase
- Previous by thread: New function's UpperCase / LowerCase
- Next by thread: Re: New function's UpperCase / LowerCase
- Index(es):
Relevant Pages
|