Skip to content

Commit 7785a40

Browse files
sglienkevincentparrett
authored andcommitted
renamed GetCountFast to GetNonEnumeratedCount
1 parent bbf6c15 commit 7785a40

11 files changed

+247
-237
lines changed

Source/Base/Collections/Spring.Collections.Base.pas

Lines changed: 58 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ interface
4949
function GetCount: Integer;
5050
function GetElementType: PTypeInfo;
5151
function GetIsEmpty: Boolean;
52-
function GetCountFast: Integer;
52+
function GetNonEnumeratedCount: Integer;
5353
function AsObject: TObject;
5454
procedure ToArray(var result);
5555
end;
@@ -101,8 +101,8 @@ TEnumerableBase = class abstract(TRefCountedObject)
101101
this: Pointer;
102102
{$REGION 'Property Accessors'}
103103
function GetCount: Integer;
104-
function GetCountFast: Integer;
105104
function GetIsEmpty: Boolean;
105+
function GetNonEnumeratedCount: Integer;
106106
{$ENDREGION}
107107
public
108108
class function NewInstance: TObject; override;
@@ -238,9 +238,9 @@ TEnumerator = class(TRefCountedObject, IEnumerator)
238238
fSource: IEnumerable;
239239
fGetCurrent: TGetCurrentFunc;
240240
function GetCount: Integer;
241-
function GetCountFast: Integer;
242241
function GetElementType: PTypeInfo;
243242
function GetIsEmpty: Boolean;
243+
function GetNonEnumeratedCount: Integer;
244244
protected
245245
function QueryInterface(const IID: TGUID; out obj): HResult; stdcall;
246246
public
@@ -313,7 +313,7 @@ TIteratorBase = record
313313
fIndex, fCount: Integer;
314314
fKind: TIteratorKind;
315315

316-
function GetCountFast: Integer;
316+
function GetNonEnumeratedCount: Integer;
317317
end;
318318

319319
TMemoizeIterator<T> = record
@@ -403,7 +403,7 @@ TIteratorBlock<T> = record
403403

404404
TEnumerableIterator<T> = class sealed(TIteratorBase<T>, IInterface, IEnumerable<T>)
405405
private
406-
function GetCountFast: Integer;
406+
function GetNonEnumeratedCount: Integer;
407407
public
408408
class function Create(const source: IEnumerable<T>; index, count: Integer;
409409
predicate: Pointer; kind: TIteratorKind): IEnumerable<T>; overload; static;
@@ -431,8 +431,8 @@ TEnumerator = record
431431
fItems: TArray<T>;
432432
{$REGION 'Property Accessors'}
433433
function GetCount: Integer;
434-
function GetCountFast: Integer;
435434
function GetItem(index: Integer): T;
435+
function GetNonEnumeratedCount: Integer;
436436
{$ENDREGION}
437437
public
438438
class function Create(const values: TArray<T>): IReadOnlyList<T>; overload; static;
@@ -573,7 +573,7 @@ TEnumerator = record
573573
fOffset: Integer;
574574
{$REGION 'Property Accessors'}
575575
function GetCount: Integer;
576-
function GetCountFast: Integer;
576+
function GetNonEnumeratedCount: Integer;
577577
{$ENDREGION}
578578
protected
579579
function GetElementType: PTypeInfo; override;
@@ -626,7 +626,7 @@ TEnumerator = record
626626
fVersion: PInteger;
627627
{$REGION 'Property Accessors'}
628628
function GetCount: Integer;
629-
function GetCountFast: Integer;
629+
function GetNonEnumeratedCount: Integer;
630630
{$ENDREGION}
631631
public
632632
constructor Create(const source: TRefCountedObject; const comparer: IComparer<T>;
@@ -678,7 +678,7 @@ TEnumerator = record
678678
{$REGION 'Property Accessors'}
679679
function GetCapacity: Integer; inline;
680680
function GetCount: Integer; inline;
681-
function GetCountFast: Integer;
681+
function GetNonEnumeratedCount: Integer;
682682
function GetOnChanged: ICollectionChangedEvent<T>;
683683
function GetOwnsObjects: Boolean; inline;
684684
procedure SetCapacity(value: Integer);
@@ -825,7 +825,7 @@ function SupportsIndexedAccess(const source: IInterface): Boolean;
825825
if not Result then
826826
begin
827827
entry := obj.GetInterfaceEntry(IPartitionOfTGuid);
828-
Result := Assigned(entry) and (IEnumerable(PByte(obj) + entry.IOffset).GetCountFast >= 0);
828+
Result := Assigned(entry) and (IEnumerable(PByte(obj) + entry.IOffset).GetNonEnumeratedCount >= 0);
829829
end;
830830
end;
831831

@@ -987,7 +987,7 @@ function IsCountInRange(const this: IEnumerable; min, max, limit: Integer): Bool
987987
var
988988
count: Integer;
989989
begin
990-
count := this.GetCountFast;
990+
count := this.GetNonEnumeratedCount;
991991
if count < 0 then
992992
count := SkipAndCountSlow(this, limit);
993993
Result := {$B+}(count >= min) and (count <= max);{$B-}
@@ -1005,7 +1005,7 @@ function TEnumerableBase.Any: Boolean;
10051005
var
10061006
count: Integer;
10071007
begin
1008-
count := IEnumerable(this).GetCountFast;
1008+
count := IEnumerable(this).GetNonEnumeratedCount;
10091009
if count >= 0 then
10101010
Result := count > 0
10111011
else
@@ -1049,7 +1049,7 @@ function TEnumerableBase.Exactly(count: Integer): Boolean;
10491049

10501050
function TEnumerableBase.GetCount: Integer;
10511051

1052-
function GetCountSlow(const this: IEnumerable): Integer;
1052+
function GetEnumeratedCount(const this: IEnumerable): Integer;
10531053
var
10541054
enumerator: IEnumerator;
10551055
begin
@@ -1060,23 +1060,23 @@ function TEnumerableBase.GetCount: Integer;
10601060
end;
10611061

10621062
begin
1063-
Result := IEnumerable(this).GetCountFast;
1063+
Result := IEnumerable(this).GetNonEnumeratedCount;
10641064
if Result < 0 then
1065-
Result := GetCountSlow(IEnumerable(this));
1065+
Result := GetEnumeratedCount(IEnumerable(this));
10661066
end;
10671067

10681068
function TEnumerableBase.GetIsEmpty: Boolean;
10691069
var
10701070
count: Integer;
10711071
begin
1072-
count := IEnumerable(this).GetCountFast;
1072+
count := IEnumerable(this).GetNonEnumeratedCount;
10731073
if count >= 0 then
10741074
Result := count = 0
10751075
else
10761076
Result := not HasAnyItems(IEnumerable(this));
10771077
end;
10781078

1079-
function TEnumerableBase.GetCountFast: Integer;
1079+
function TEnumerableBase.GetNonEnumeratedCount: Integer;
10801080
begin
10811081
// implementing IReadOnlyCollection is an indicator for having its own count
10821082
if GetInterfaceEntry(IReadOnlyCollectionOfTGuid) <> nil then
@@ -1778,7 +1778,7 @@ function TEnumerableBase<T>.Skip(count: Integer): IEnumerable<T>;
17781778
Result := IEnumerable<T>(this)
17791779
else
17801780
begin
1781-
maxCount := IEnumerable<T>(this).GetCountFast;
1781+
maxCount := IEnumerable<T>(this).GetNonEnumeratedCount;
17821782
if maxCount >= 0 then
17831783
maxCount := MaxInt - count;
17841784
Result := TEnumerableIterator<T>.Create(IEnumerable<T>(this),
@@ -2099,18 +2099,18 @@ function TEnumerableWrapper.GetIsEmpty: Boolean;
20992099
Result := fSource.IsEmpty;
21002100
end;
21012101

2102+
function TEnumerableWrapper.GetNonEnumeratedCount: Integer;
2103+
begin
2104+
Result := fSource.GetNonEnumeratedCount;
2105+
end;
2106+
21022107
function TEnumerableWrapper.QueryInterface(const IID: TGUID; out obj): HResult;
21032108
begin
21042109
Result := inherited QueryInterface(IID, obj);
21052110
if Result <> S_OK then
21062111
Result := fSource.QueryInterface(IID, obj);
21072112
end;
21082113

2109-
function TEnumerableWrapper.GetCountFast: Integer;
2110-
begin
2111-
Result := fSource.GetCountFast;
2112-
end;
2113-
21142114
{$ENDREGION}
21152115

21162116

@@ -2509,11 +2509,6 @@ function TInnerCollection<T>.GetCount: Integer;
25092509
Result := fHashTable.Count;
25102510
end;
25112511

2512-
function TInnerCollection<T>.GetCountFast: Integer;
2513-
begin
2514-
Result := fHashTable.Count;
2515-
end;
2516-
25172512
function TInnerCollection<T>.GetElementType: PTypeInfo;
25182513
begin
25192514
Result := fElementType;
@@ -2531,6 +2526,11 @@ function TInnerCollection<T>.GetEnumerator: IEnumerator<T>; //FI:W521
25312526
end;
25322527
end;
25332528

2529+
function TInnerCollection<T>.GetNonEnumeratedCount: Integer;
2530+
begin
2531+
Result := fHashTable.Count;
2532+
end;
2533+
25342534
function TInnerCollection<T>.ToArray: TArray<T>;
25352535
var
25362536
hashTable: PHashTable;
@@ -2653,11 +2653,6 @@ function TSortedKeyCollection<T>.GetCount: Integer;
26532653
Result := fTree.Count;
26542654
end;
26552655

2656-
function TSortedKeyCollection<T>.GetCountFast: Integer;
2657-
begin
2658-
Result := fTree.Count;
2659-
end;
2660-
26612656
function TSortedKeyCollection<T>.GetEnumerator: IEnumerator<T>; //FI:W521
26622657
begin
26632658
_AddRef;
@@ -2670,6 +2665,11 @@ function TSortedKeyCollection<T>.GetEnumerator: IEnumerator<T>; //FI:W521
26702665
end;
26712666
end;
26722667

2668+
function TSortedKeyCollection<T>.GetNonEnumeratedCount: Integer;
2669+
begin
2670+
Result := fTree.Count;
2671+
end;
2672+
26732673
function TSortedKeyCollection<T>.ToArray: TArray<T>;
26742674
var
26752675
tree: TBinaryTree;
@@ -2813,16 +2813,6 @@ function TCircularArrayBuffer<T>.GetCount: Integer;
28132813
Result := fCount and CountMask;
28142814
end;
28152815

2816-
function TCircularArrayBuffer<T>.GetCountFast: Integer;
2817-
begin
2818-
{$IFDEF DELPHIXE7_UP}
2819-
if GetTypeKind(T) <> tkClass then
2820-
Result := fCount
2821-
else
2822-
{$ENDIF}
2823-
Result := fCount and CountMask;
2824-
end;
2825-
28262816
function TCircularArrayBuffer<T>.GetEnumerator: IEnumerator<T>; //FI:W521
28272817
begin
28282818
_AddRef;
@@ -2836,6 +2826,16 @@ function TCircularArrayBuffer<T>.GetEnumerator: IEnumerator<T>; //FI:W521
28362826
end;
28372827
end;
28382828

2829+
function TCircularArrayBuffer<T>.GetNonEnumeratedCount: Integer;
2830+
begin
2831+
{$IFDEF DELPHIXE7_UP}
2832+
if GetTypeKind(T) <> tkClass then
2833+
Result := fCount
2834+
else
2835+
{$ENDIF}
2836+
Result := fCount and CountMask;
2837+
end;
2838+
28392839
function TCircularArrayBuffer<T>.GetOnChanged: ICollectionChangedEvent<T>;
28402840
begin
28412841
Result := fOnChanged;
@@ -3310,7 +3310,7 @@ function TIteratorBlock.GetEnumeratorPartitionFromEnd: Boolean;
33103310
var
33113311
count, index: Integer;
33123312
begin
3313-
count := Source.GetCountFast;
3313+
count := Source.GetNonEnumeratedCount;
33143314

33153315
if Self.Index < 0 then
33163316
begin
@@ -3923,18 +3923,18 @@ function TIteratorBlock<T>.ToArray: Boolean;
39233923

39243924
{$REGION 'TIteratorFields'}
39253925

3926-
function TIteratorBase.GetCountFast: Integer;
3926+
function TIteratorBase.GetNonEnumeratedCount: Integer;
39273927
var
39283928
count: Integer;
39293929
begin
39303930
case fKind of //FI:W535
39313931
TIteratorKind.Concat:
39323932
begin
3933-
Result := fSource.GetCountFast;
3933+
Result := fSource.GetNonEnumeratedCount;
39343934
if Result >= 0 then
39353935
begin
39363936
count := Result;
3937-
Result := IEnumerable(fPredicate).GetCountFast;
3937+
Result := IEnumerable(fPredicate).GetNonEnumeratedCount;
39383938
if Result >= 0 then
39393939
{$Q+}
39403940
Inc(Result, count);
@@ -3949,13 +3949,13 @@ function TIteratorBase.GetCountFast: Integer;
39493949
Exit(Result and CountMask)
39503950
end;
39513951
TIteratorKind.Ordered, TIteratorKind.Reversed, TIteratorKind.Shuffled:
3952-
Exit(fSource.GetCountFast);
3952+
Exit(fSource.GetNonEnumeratedCount);
39533953
TIteratorKind.Partition:
39543954
begin
39553955
Result := fCount;
39563956
if Result > 0 then
39573957
begin
3958-
Result := fSource.GetCountFast;
3958+
Result := fSource.GetNonEnumeratedCount;
39593959
if Result > 0 then
39603960
begin
39613961
Dec(Result, fIndex);
@@ -3971,7 +3971,7 @@ function TIteratorBase.GetCountFast: Integer;
39713971
begin
39723972
if fIndex = 0 then
39733973
begin
3974-
Result := fSource.GetCountFast;
3974+
Result := fSource.GetNonEnumeratedCount;
39753975
if Result > 0 then
39763976
begin
39773977
Dec(Result, fCount);
@@ -3984,7 +3984,7 @@ function TIteratorBase.GetCountFast: Integer;
39843984
Result := fCount;
39853985
if Result > 0 then
39863986
begin
3987-
Result := fSource.GetCountFast;
3987+
Result := fSource.GetNonEnumeratedCount;
39883988
if Result > fCount then
39893989
Result := fCount;
39903990
end;
@@ -4286,9 +4286,9 @@ class function TEnumerableIterator<T>.Create(const source: IEnumerable<T>;
42864286
Result := iterator;
42874287
end;
42884288

4289-
function TEnumerableIterator<T>.GetCountFast: Integer;
4289+
function TEnumerableIterator<T>.GetNonEnumeratedCount: Integer;
42904290
begin
4291-
Result := PIteratorBase(@fSource).GetCountFast;
4291+
Result := PIteratorBase(@fSource).GetNonEnumeratedCount;
42924292
end;
42934293

42944294
{$ENDREGION}
@@ -4338,11 +4338,6 @@ function TArrayIterator<T>.GetCount: Integer;
43384338
Result := DynArrayLength(fItems);
43394339
end;
43404340

4341-
function TArrayIterator<T>.GetCountFast: Integer;
4342-
begin
4343-
Result := DynArrayLength(fItems);
4344-
end;
4345-
43464341
function TArrayIterator<T>.GetEnumerator: IEnumerator<T>; //FI:W521
43474342
begin
43484343
with PEnumerator(TEnumeratorBlock.Create(@Result, @TEnumerator.Enumerator_Vtable,
@@ -4360,6 +4355,11 @@ function TArrayIterator<T>.GetItem(index: Integer): T;
43604355
Result := fItems[index];
43614356
end;
43624357

4358+
function TArrayIterator<T>.GetNonEnumeratedCount: Integer;
4359+
begin
4360+
Result := DynArrayLength(fItems);
4361+
end;
4362+
43634363
function TArrayIterator<T>.IndexOf(const item: T): Integer;
43644364
begin
43654365
Result := IndexOf(item, 0, DynArrayLength(fItems));

0 commit comments

Comments
 (0)