Re: I need the fastest routine
- From: Pierre le Riche <pleriche@xxxxxxxxxxx>
- Date: Sat, 05 Jul 2008 23:03:01 +0200
Hi Clément,
Unfortunately it's not fast enough. I need more speed. I just wanted to be sure this routine is ok, or if there's some tricks to make it faster.
I haven't benchmarked it, but I reckon the routine below should be faster:
procedure MinMaxArray(const aArray: array of Integer; out aMax, aMin: Integer);
var
LInd, LTempMin, LTempMax, LArrVal: Integer;
begin
LTempMin := MaxInt;
LTempMax := MinInt;
for LInd := 0 to High(aArray) do
begin
{Get the array value}
LArrVal := aArray[LInd];
{Update the minimum}
LTempMin := LArrVal + ((-Ord(LTempMin < LArrVal))
and (LTempMin - LArrVal));
{Update the maximum}
LTempMax := LArrVal + ((-Ord(LTempMax > LArrVal))
and (LTempMax - LArrVal));
end;
aMin := LTempMin;
aMax := LTempMax;
end;
Regards,
Pierre
.
- Follow-Ups:
- Re: I need the fastest routine
- From: Rudy Velthuis [TeamB]
- Re: I need the fastest routine
- References:
- I need the fastest routine
- From: Clément Doss
- I need the fastest routine
- Prev by Date: Re: I need the fastest routine
- Next by Date: Re: I need the fastest routine
- Previous by thread: Re: I need the fastest routine
- Next by thread: Re: I need the fastest routine
- Index(es):
Relevant Pages
|