summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5db5b1f)
raw | patch | inline | side by side (parent: 5db5b1f)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 30 Aug 2017 11:13:50 +0000 (14:13 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Wed, 30 Aug 2017 11:14:40 +0000 (14:14 +0300) |
src/game/g_grid.pas | patch | blob | history | |
src/shared/a_modes.inc | patch | blob | history | |
src/shared/hashtable.pas | patch | blob | history |
diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas
index 5b88258c09ffb54111ce0d3ac116196d1b8a5ed5..475cb68d7ec3b961c324f504bcf802230ae2bbfc 100644 (file)
--- a/src/game/g_grid.pas
+++ b/src/game/g_grid.pas
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
diff --git a/src/shared/a_modes.inc b/src/shared/a_modes.inc
index 2834ce096081b14bcbdaba59c75d61a91587a233..d6cae35799ceca7cc83cb469b1077c73eb726e6d 100644 (file)
--- a/src/shared/a_modes.inc
+++ b/src/shared/a_modes.inc
{$MODESWITCH PROPERTIES+}
{$MODESWITCH REPEATFORWARD+} // Implementation and Forward declaration must match completely.
{$MODESWITCH RESULT+}
-{$MODESWITCH TYPEHELPERS-} // Allow the use of type helpers.
-{$MODESWITCH UNICODESTRINGS-}
+{$MODESWITCH TYPEHELPERS+} // Allow the use of type helpers.
{$MODESWITCH UNICODESTRINGS-}
{$HINTS OFF}
{$ELSE}
{$STACKFRAMES OFF}
+ {$HINTS OFF}
+ {$DEFINE D2F_MORE_OPTIM}
{$ENDIF}
{$WARNINGS ON}
{$NOTES ON}
-// include support for text maps
-{$DEFINE D2D_NEW_MAP_READER}
+{$IF DEFINED(D2F_DEBUG_OPTIM) or DEFINED(D2F_MORE_OPTIM)}
+ {$OPTIMIZATION DEADVALUES}
+ {$OPTIMIZATION CONSTPROP}
+ {$OPTIMIZATION DEADSTORE}
+{$ENDIF}
{$IFDEF MSWINDOWS}
{$IFNDEF WINDOWS}
index 531b3a3b71212661ee5db77d70898c33617d20eb..190d4e62b57cb9c9b9941bc78dec401239aaf0d2 100644 (file)
--- a/src/shared/hashtable.pas
+++ b/src/shared/hashtable.pas
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;