Skip to content

Commit abe02a8

Browse files
committed
only set this in TEnumerableBase.Create - all implementations ensure that inheriting interfaces use the same IMT field as IEnumerable<T> does
1 parent afc76f3 commit abe02a8

File tree

3 files changed

+4
-15
lines changed

3 files changed

+4
-15
lines changed

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

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -593,8 +593,6 @@ TListBase<T> = class abstract(TCollectionBase<T>)
593593
{$ENDREGION}
594594
function CreateList: IList<T>; virtual;
595595
public
596-
constructor Create; override;
597-
598596
function Add(const item: T): Boolean;
599597

600598
function Remove(const item: T): Boolean;
@@ -836,7 +834,8 @@ function TEnumerableBase.GetIsEmpty: Boolean;
836834
constructor TEnumerableBase<T>.Create;
837835
begin
838836
inherited Create;
839-
fComparer := IComparer<T>(_LookupVtableInfo(giComparer, GetElementType, SizeOf(T)));
837+
if not Assigned(fComparer) then
838+
fComparer := IComparer<T>(_LookupVtableInfo(giComparer, GetElementType, SizeOf(T)));
840839
end;
841840

842841
constructor TEnumerableBase<T>.Create(const comparer: IComparer<T>);
@@ -1791,7 +1790,6 @@ function TSourceIterator<T>.GetElementType: PTypeInfo;
17911790
constructor TCollectionBase<T>.Create;
17921791
begin
17931792
inherited Create;
1794-
Pointer(this) := Pointer(PByte(Self) + GetInterfaceEntry(ICollection<T>).IOffset);
17951793
UpdateNotify(Self);
17961794
end;
17971795

@@ -2515,8 +2513,6 @@ constructor TMapBase<TKey, T>.Create;
25152513
inherited Create;
25162514
fOnKeyChanged := TCollectionChangedEventImpl<TKey>.Create;
25172515
fOnValueChanged := TCollectionChangedEventImpl<T>.Create;
2518-
2519-
Pointer(this) := Pointer(PByte(Self) + GetInterfaceEntry(IMap<TKey, T>).IOffset);
25202516
end;
25212517

25222518
destructor TMapBase<TKey, T>.Destroy;
@@ -2601,12 +2597,6 @@ procedure TMapBase<TKey, T>.ValueChanged(const item: T;
26012597

26022598
{$REGION 'TListBase<T>'}
26032599

2604-
constructor TListBase<T>.Create;
2605-
begin
2606-
inherited Create;
2607-
Pointer(this) := Pointer(PByte(Self) + GetInterfaceEntry(IList<T>).IOffset);
2608-
end;
2609-
26102600
function TListBase<T>.CreateList: IList<T>;
26112601
begin
26122602
Result := TList<T>.Create;

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1984,7 +1984,8 @@ constructor TFoldedList<T>.Create(elementType: PTypeInfo;
19841984
const comparer: IComparer<T>; ownsObjects: Boolean);
19851985
begin
19861986
fElementType := elementType;
1987-
inherited Create(comparer);
1987+
fComparer := comparer;
1988+
inherited Create;
19881989
SetOwnsObjects(ownsObjects);
19891990
end;
19901991

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,8 +149,6 @@ constructor TAbstractStack<T>.Create;
149149
begin
150150
inherited Create;
151151
fOnChanged := TCollectionChangedEventImpl<T>.Create;
152-
153-
Pointer(this) := Pointer(PByte(Self) + GetInterfaceEntry(IStack<T>).IOffset);
154152
end;
155153

156154
constructor TAbstractStack<T>.Create(const values: array of T);

0 commit comments

Comments
 (0)