grijjy / GrijjyFoundation

Foundation classes used by other Grijjy repositories
Other
246 stars 86 forks source link

D12 Athens gives compiler hint(s) #54

Closed TommiPrami closed 11 months ago

TommiPrami commented 11 months ago

[dcc32 Hint] Grijjy.Collections.pas(909): H2077 Value assigned to 'TgoReadOnlySet.Contains' never used

and

[dcc32 Hint] Grijjy.Collections.pas(1807): H2077 Value assigned to 'TgoValueDictionary<TKey,TValue>.ContainsKey' never used

Propose changing them into:

function TgoReadOnlySet.Contains(const AItem: T): Boolean; var Mask, Index, HashCode, HC: Integer; begin Result := False;

if FCount = 0 then Exit;

HashCode := FComparer.GetHashCode(AItem) and $7FFFFFFF; Mask := Length(FItems) - 1; Index := HashCode and Mask;

while True do begin HC := FItems[Index].HashCode; if (HC = EMPTY_HASH) then Exit(False);

if (HC = HashCode) and FComparer.Equals(FItems[Index].Item, AItem) then
  Exit(True);

Index := (Index + 1) and Mask;

end; end;

and

function TgoValueDictionary<TKey, TValue>.ContainsKey( const AKey: TKey): Boolean; var Mask, Index, HashCode, HC: Integer; begin Result := False;

if FCount = 0 then Exit;

HashCode := FComparer.GetHashCode(AKey) and $7FFFFFFF; Mask := Length(FItems) - 1; Index := HashCode and Mask;

while True do begin HC := FItems[Index].HashCode; if (HC = EMPTY_HASH) then Exit(False);

if (HC = HashCode) and FComparer.Equals(FItems[Index].Key, AKey) then
  Exit(True);

Index := (Index + 1) and Mask;

end; end;

-Tee-

erikvanbilsen commented 11 months ago

I implemented your suggested changes, but since I haven't installed Delphi 12 yet, I cannot confirm if this removes the hints.

TommiPrami commented 11 months ago

It removes them in D12

On Fri, Nov 10, 2023, 18:15 Erik van Bilsen @.***> wrote:

I implemented your suggested changes, but since I haven't installed Delphi 12 yet, I cannot confirm if this removes the hints.

— Reply to this email directly, view it on GitHub https://github.com/grijjy/GrijjyFoundation/issues/54#issuecomment-1806024878, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA7E2H76CAF5QIJ7WN3CHWLYDZHLXAVCNFSM6AAAAAA7FUSNWCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBWGAZDIOBXHA . You are receiving this because you authored the thread.Message ID: @.***>