diff --git a/.gitattributes b/.gitattributes index e5cb953131..fb63d906e7 100644 --- a/.gitattributes +++ b/.gitattributes @@ -17616,6 +17616,7 @@ tests/webtbs/tw36544b.pp svneol=native#text/pascal tests/webtbs/tw3661.pp svneol=native#text/plain tests/webtbs/tw3666.pp svneol=native#text/plain tests/webtbs/tw3669.pp svneol=native#text/plain +tests/webtbs/tw36698.pp -text svneol=native#text/pascal tests/webtbs/tw3676.pp svneol=native#text/plain tests/webtbs/tw3681.pp svneol=native#text/plain tests/webtbs/tw3683.pp svneol=native#text/plain diff --git a/packages/fcl-stl/src/gvector.pp b/packages/fcl-stl/src/gvector.pp index 834045c622..9724f1248b 100644 --- a/packages/fcl-stl/src/gvector.pp +++ b/packages/fcl-stl/src/gvector.pp @@ -33,7 +33,8 @@ type procedure SetValue(Position: SizeUInt; const Value: T); inline; function GetValue(Position: SizeUInt): T; inline; function GetMutable(Position: SizeUInt): PT; inline; - procedure IncreaseCapacity; inline; + function NewCapacity: SizeUInt; + procedure IncreaseCapacity; const // todo: move these constants to implementation when @@ -162,7 +163,7 @@ begin inc(FDataSize); end; -procedure TVector.IncreaseCapacity(); +function TVector.NewCapacity: SizeUInt; const // if size is small, multiply by 2; // if size bigger but <256M, inc by 1/8*size; @@ -174,15 +175,20 @@ var begin DataSize:=FCapacity*SizeOf(T); if FCapacity=0 then - FCapacity:=4 + Result:=4 else if DataSize; + + +class function THash.Hash(aValue: Integer; n: SizeUInt): SizeUInt; +begin + aValue := aValue xor aValue shr 20 xor aValue shr 12; + Result := SizeUInt(aValue xor aValue shr 7 xor aValue shr 4) and (n-1); +end; + +procedure Test; +var + Map: TMap; + I: Integer; +begin + Map := TMap.Create; + try + for I := 1 to TestSize do + Map.Insert(I, I); + finally + Map.Free; + end; +end; + +begin + Test; +end.