temp: Integer;
ccidx, curci: Integer;
lastGA: Integer = -1;
- ga, x, y: Integer;
+ ga: Integer;
gw, gh, minx, miny, maxx, maxy: Integer;
cc: PGridCell;
px: PBodyProxyRec;
if dbgShowTraceLog then e_LogWritefln('optimized htrace; wklen=%d', [wklen]);
{$ENDIF}
ga := (yptr^ div tsize)*gw+(xptr^ div tsize);
- // one of those will never change
- x := xptr^+minx;
- y := yptr^+miny;
{$IF DEFINED(D2F_DEBUG)}
if hopt then
begin
- if (y <> ay0) then raise Exception.Create('htrace fatal internal error');
+ if (yptr^ <> ay0) then raise Exception.Create('htrace fatal internal error');
end
else
begin
- if (x <> ax0) then raise Exception.Create('vtrace fatal internal error');
+ if (xptr^ <> ax0) then raise Exception.Create('vtrace fatal internal error');
end;
{$ENDIF}
while (wklen > 0) do
begin
{$IF DEFINED(D2F_DEBUG)}
- if dbgShowTraceLog then e_LogWritefln(' htrace; ga=%d; x=%d, y=%d; y=%d; y=%d', [ga, xptr^+minx, yptr^+miny, y, ay0]);
+ if dbgShowTraceLog then e_LogWritefln(' htrace; ga=%d; x=%d, y=%d; ay0=%d', [ga, xptr^+minx, yptr^+miny, ay0]);
{$ENDIF}
// new tile?
if (ga <> lastGA) then
lastGA := ga;
ccidx := mGrid[lastGA];
// convert coords to map (to avoid ajdusting coords inside the loop)
- if hopt then x := xptr^+minx else y := yptr^+miny;
while (ccidx <> -1) do
begin
cc := @mCells[ccidx];
begin
// process cell
curci := ccidx;
- // convert coords to map (to avoid ajdusting coords inside the loop)
- x := xptr^+minx;
- y := yptr^+miny;
// process cell list
while (curci <> -1) do
begin
private
type
+ TEntryArray = array of TEntry;
+
TValEnumerator = record
private
- mEntries: PEntry;
+ mEntries: TEntryArray;
mFirstEntry, mLastEntry, cur: Integer;
public
- constructor Create (aents: PEntry; afirst, alast: Integer);
- function MoveNext: Boolean;
- function getCurrent (): ValueT;
+ constructor Create (aents: TEntryArray; afirst, alast: Integer);
+ function MoveNext (): Boolean; inline;
+ function getCurrent (): ValueT; inline;
property Current: ValueT read getCurrent;
end;
TKeyEnumerator = record
private
- mEntries: PEntry;
+ mEntries: TEntryArray;
mFirstEntry, mLastEntry, cur: Integer;
public
- constructor Create (aents: PEntry; afirst, alast: Integer);
- function MoveNext: Boolean;
- function getCurrent (): KeyT;
+ constructor Create (aents: TEntryArray; afirst, alast: Integer);
+ function MoveNext (): Boolean; inline;
+ function getCurrent (): KeyT; inline;
property Current: KeyT read getCurrent;
end;
TKeyValEnumerator = record
private
- mEntries: PEntry;
+ mEntries: TEntryArray;
mFirstEntry, mLastEntry, cur: Integer;
public
- constructor Create (aents: PEntry; afirst, alast: Integer);
- function MoveNext: Boolean;
- function getCurrent (): PEntry;
+ constructor Create (aents: TEntryArray; afirst, alast: Integer);
+ function MoveNext (): Boolean; inline;
+ function getCurrent (): PEntry; inline;
property Current: PEntry read getCurrent;
end;
equfn: TEquFn;
mBuckets: array of PEntry; // entries, points to mEntries elements
mBucketsUsed: Integer;
- mEntries: array of TEntry;
+ mEntries: TEntryArray;
{$IFDEF RBHASH_SANITY_CHECKS}
mEntriesUsed: Integer;
{$ENDIF}
// enumerators
function THashBase.GetEnumerator (): TValEnumerator;
begin
- if (Length(mEntries) > 0) then result := TValEnumerator.Create(@mEntries[0], mFirstEntry, mLastEntry)
+ if (Length(mEntries) > 0) then result := TValEnumerator.Create(mEntries, mFirstEntry, mLastEntry)
else result := TValEnumerator.Create(nil, -1, -1);
end;
function THashBase.byKey (): TKeyEnumerator;
begin
- if (Length(mEntries) > 0) then result := TKeyEnumerator.Create(@mEntries[0], mFirstEntry, mLastEntry)
+ if (Length(mEntries) > 0) then result := TKeyEnumerator.Create(mEntries, mFirstEntry, mLastEntry)
else result := TKeyEnumerator.Create(nil, -1, -1);
end;
function THashBase.byValue (): TValEnumerator;
begin
- if (Length(mEntries) > 0) then result := TValEnumerator.Create(@mEntries[0], mFirstEntry, mLastEntry)
+ if (Length(mEntries) > 0) then result := TValEnumerator.Create(mEntries, mFirstEntry, mLastEntry)
else result := TValEnumerator.Create(nil, -1, -1);
end;
function THashBase.byKeyValue (): TKeyValEnumerator; // PEntry
begin
- if (Length(mEntries) > 0) then result := TKeyValEnumerator.Create(@mEntries[0], mFirstEntry, mLastEntry)
+ if (Length(mEntries) > 0) then result := TKeyValEnumerator.Create(mEntries, mFirstEntry, mLastEntry)
else result := TKeyValEnumerator.Create(nil, -1, -1);
end;
// ////////////////////////////////////////////////////////////////////////// //
-constructor THashBase.TValEnumerator.Create (aents: PEntry; afirst, alast: Integer);
+constructor THashBase.TValEnumerator.Create (aents: TEntryArray; afirst, alast: Integer);
begin
mEntries := aents;
mFirstEntry := afirst;
cur := mFirstEntry-1;
end;
-function THashBase.TValEnumerator.MoveNext: Boolean;
+function THashBase.TValEnumerator.MoveNext (): Boolean; inline;
begin
Inc(cur);
while (cur <= mLastEntry) do
result := false;
end;
-function THashBase.TValEnumerator.getCurrent (): ValueT;
+function THashBase.TValEnumerator.getCurrent (): ValueT; inline;
begin
result := mEntries[cur].value;
end;
// ////////////////////////////////////////////////////////////////////////// //
-constructor THashBase.TKeyEnumerator.Create (aents: PEntry; afirst, alast: Integer);
+constructor THashBase.TKeyEnumerator.Create (aents: TEntryArray; afirst, alast: Integer);
begin
mEntries := aents;
mFirstEntry := afirst;
cur := mFirstEntry-1;
end;
-function THashBase.TKeyEnumerator.MoveNext: Boolean;
+function THashBase.TKeyEnumerator.MoveNext (): Boolean; inline;
begin
Inc(cur);
while (cur <= mLastEntry) do
result := false;
end;
-function THashBase.TKeyEnumerator.getCurrent (): KeyT;
+function THashBase.TKeyEnumerator.getCurrent (): KeyT; inline;
begin
result := mEntries[cur].key;
end;
// ////////////////////////////////////////////////////////////////////////// //
-constructor THashBase.TKeyValEnumerator.Create (aents: PEntry; afirst, alast: Integer);
+constructor THashBase.TKeyValEnumerator.Create (aents: TEntryArray; afirst, alast: Integer);
begin
mEntries := aents;
mFirstEntry := afirst;
cur := mFirstEntry-1;
end;
-function THashBase.TKeyValEnumerator.MoveNext: Boolean;
+function THashBase.TKeyValEnumerator.MoveNext (): Boolean; inline;
begin
Inc(cur);
while (cur <= mLastEntry) do
result := false;
end;
-function THashBase.TKeyValEnumerator.getCurrent (): PEntry;
+function THashBase.TKeyValEnumerator.getCurrent (): PEntry; inline;
begin
- result := mEntries+cur;
+ result := @mEntries[cur];
end;