Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Give uniq === semantics, not eq.
Also sink the for that is being gathered. Once the sink branch lands,
this should decrease memory usage also.
  • Loading branch information
jnthn committed Dec 10, 2012
1 parent 53daeff commit 8e02c1e
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/core/List.pm
Expand Up @@ -310,14 +310,13 @@ my class List does Positional {

# This needs a way of taking a user-defined comparison
# specifier, but AFAIK nothing has been spec'd yet.
# CHEAT: Almost certainly should be hashed on something
# other than the stringification of the objects.
method uniq() {
my %seen;
gather for @.list {
unless %seen{$_} {
my $seen := nqp::hash();
gather sink for @.list {
my str $which = nqp::unbox_s($_.WHICH);
unless nqp::existskey($seen, $which) {
take $_;
%seen{$_} = 1;
nqp::bindkey($seen, $which, 1);
}
}
}
Expand Down

0 comments on commit 8e02c1e

Please sign in to comment.