Skip to content

Commit

Permalink
Optimize List.clear methods to avoid clearing unused memory
Browse files Browse the repository at this point in the history
Fixes goldmansachs/gs-collections#33

Signed-off-by: Christopher Clark <csquared@cs.washington.edu>
  • Loading branch information
chrisc36 committed Sep 26, 2016
1 parent 0db19cf commit ec1fd2a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class <name>ArrayList extends Abstract<name>Iterable

public void clear()
{
Arrays.fill(this.items, <(zero.(type))>);
Arrays.fill(this.items, 0, size, <(zero.(type))>);
this.size = 0;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ public FastList<T> clone()
@Override
public void clear()
{
Arrays.fill(this.items, null);
Arrays.fill(this.items, 0, size, null);
this.size = 0;
}

Expand Down

0 comments on commit ec1fd2a

Please sign in to comment.