mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #10307 from silverstripe-terraformers/feature/removal-all-enhancement
ENH: RemoveAll() memory performance enhancement.
This commit is contained in:
commit
c0ff638cd8
@ -1174,7 +1174,7 @@ class DataList extends ViewableData implements SS_List, Filterable, Sortable, Li
|
|||||||
*/
|
*/
|
||||||
public function removeAll()
|
public function removeAll()
|
||||||
{
|
{
|
||||||
foreach ($this as $item) {
|
foreach ($this->getGenerator() as $item) {
|
||||||
$this->remove($item);
|
$this->remove($item);
|
||||||
}
|
}
|
||||||
return $this;
|
return $this;
|
||||||
|
@ -458,6 +458,17 @@ class DataListTest extends SapphireTest
|
|||||||
$this->assertNull($list->byID($id));
|
$this->assertNull($list->byID($id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test DataList->removeAll()
|
||||||
|
*/
|
||||||
|
public function testRemoveAll()
|
||||||
|
{
|
||||||
|
$list = Team::get();
|
||||||
|
$this->assertGreaterThan(0, $list->count());
|
||||||
|
$list->removeAll();
|
||||||
|
$this->assertCount(0, $list);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test DataList->canSortBy()
|
* Test DataList->canSortBy()
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user