# HG changeset patch # User Jordan Miner # Date 1280122153 18000 # Node ID 7cf356729515ea3ab5c77cb0ca2d9f044471bbc2 # Parent 366e1323bcb940fc11156908626e43d4adb5f01c Set removed items in a List to T.init. T could be a struct containing a pointer or even be a pointer itself. diff -r 366e1323bcb9 -r 7cf356729515 dynamin/core/list.d --- a/dynamin/core/list.d Mon Jul 19 21:42:06 2010 -0500 +++ b/dynamin/core/list.d Mon Jul 26 00:29:13 2010 -0500 @@ -159,8 +159,7 @@ throw new Exception("List.pop() - List is empty"); T item = _data[_count-1]; // must null out to allow to be collected - static if(is(T == class) || is(T == interface)) - _data[_count-1] = cast(T)null; + _data[_count-1] = T.init; --_count; static if(changeNotification) whenChanged(ListChangeType.Removed, item, T.init, _count); @@ -181,8 +180,7 @@ for(uint i = index + 1; i < _count; ++i) _data[i-1] = _data[i]; // must null out to allow to be collected - static if(is(T == class) || is(T == interface)) - _data[_count-1] = cast(T)null; + _data[_count-1] = T.init; --_count; static if(changeNotification) @@ -201,8 +199,7 @@ static if(changeNotification) whenChanged(ListChangeType.Removed, _data[_count-1], T.init, _count-1); // must null out to allow to be collected - static if(is(T == class) || is(T == interface)) - data[_count-1] = cast(T)null; + data[_count-1] = T.init; } } uint find(T item) {