From: Ketmar Dark Date: Wed, 30 Aug 2017 11:13:50 +0000 (+0300) Subject: cosmetic fixes, optimization flag changes X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=4d64aecc835437d733321a8497b4c872c2b1c085;p=d2df-sdl.git cosmetic fixes, optimization flag changes --- diff --git a/src/game/g_grid.pas b/src/game/g_grid.pas index 5b88258..475cb68 100644 --- a/src/game/g_grid.pas +++ b/src/game/g_grid.pas @@ -2039,7 +2039,7 @@ var 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; @@ -2254,23 +2254,20 @@ begin 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 @@ -2278,7 +2275,6 @@ begin 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]; @@ -2395,9 +2391,6 @@ begin 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 2834ce0..d6cae35 100644 --- a/src/shared/a_modes.inc +++ b/src/shared/a_modes.inc @@ -24,8 +24,7 @@ {$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-} @@ -59,12 +58,17 @@ {$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} diff --git a/src/shared/hashtable.pas b/src/shared/hashtable.pas index 531b3a3..190d4e6 100644 --- a/src/shared/hashtable.pas +++ b/src/shared/hashtable.pas @@ -52,36 +52,38 @@ type 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; @@ -90,7 +92,7 @@ type 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} @@ -919,31 +921,31 @@ end; // 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; @@ -951,7 +953,7 @@ begin cur := mFirstEntry-1; end; -function THashBase.TValEnumerator.MoveNext: Boolean; +function THashBase.TValEnumerator.MoveNext (): Boolean; inline; begin Inc(cur); while (cur <= mLastEntry) do @@ -961,14 +963,14 @@ begin 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; @@ -976,7 +978,7 @@ begin cur := mFirstEntry-1; end; -function THashBase.TKeyEnumerator.MoveNext: Boolean; +function THashBase.TKeyEnumerator.MoveNext (): Boolean; inline; begin Inc(cur); while (cur <= mLastEntry) do @@ -986,14 +988,14 @@ begin 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; @@ -1001,7 +1003,7 @@ begin cur := mFirstEntry-1; end; -function THashBase.TKeyValEnumerator.MoveNext: Boolean; +function THashBase.TKeyValEnumerator.MoveNext (): Boolean; inline; begin Inc(cur); while (cur <= mLastEntry) do @@ -1011,9 +1013,9 @@ begin result := false; end; -function THashBase.TKeyValEnumerator.getCurrent (): PEntry; +function THashBase.TKeyValEnumerator.getCurrent (): PEntry; inline; begin - result := mEntries+cur; + result := @mEntries[cur]; end;