Skip to content

Commit

Permalink
MMD Any .list/.flat/.eager/,hash
Browse files Browse the repository at this point in the history
In the hopes it will get better optimized
  • Loading branch information
lizmat committed Sep 5, 2014
1 parent 3f87260 commit ca00625
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions src/core/Any.pm
Expand Up @@ -39,25 +39,26 @@ my class Any { # declared in BOOTSTRAP
fail "Can not remove elements from a {self.^name}";
}

method list() {
nqp::p6list(
self.DEFINITE ?? nqp::list(self) !! nqp::list(), List, Mu
);
}
method flat() {
nqp::p6list(
self.DEFINITE ?? nqp::list(self) !! nqp::list(), List, Bool::True
);
}
method eager() {
nqp::p6list(
self.DEFINITE ?? nqp::list(self) !! nqp::list(), List, Bool::True
).eager;
proto method list(|) { * }
multi method list(Any:U:) { nqp::p6list(nqp::list(), List, Mu) }
multi method list(Any:D:) { nqp::p6list(nqp::list(self), List, Mu) }

proto method flat(|) { * }
multi method flat(Any:U:) { nqp::p6list(nqp::list(), List, Bool::True) }
multi method flat(Any:D:) { nqp::p6list(nqp::list(self), List, Bool::True) }

proto method eager(|) { * }
multi method eager(Any:U:) {
nqp::p6list(nqp::list(), List, Bool::True).eager;
}
method hash() {
my % = self.DEFINITE ?? self !! ();
multi method eager(Any:D:) {
nqp::p6list(nqp::list(self), List, Bool::True).eager;
}

proto method hash(|) { * }
multi method hash(Any:U:) { % = () }
multi method hash(Any:D:) { % = self }

# derived from .list
method Parcel() { self.list.Parcel }
method elems() { self.list.elems }
Expand Down

0 comments on commit ca00625

Please sign in to comment.