Skip to content
Permalink
Browse files

Streamline Map.gist

- makes it about 20% faster still
- together with the Map.sort improvements now 2.5x as fast
- on a 500 element Map
  • Loading branch information...
lizmat committed Jan 7, 2019
1 parent 7229c67 commit b4d114a312a441c12145bb40cc8c3ecc660e95d8
Showing with 3 additions and 6 deletions.
  1. +3 −6 src/core/Map.pm6
@@ -213,12 +213,9 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP
}

multi method gist(Map:D: --> Str:D) {
self.^name ~ '.new((' ~ self.sort.map({
state $i = 0;
++$i == 101 ?? '...'
!! $i == 102 ?? last()
!! .gist
}).join(', ') ~ '))'
my @pairs = self.sort.head(100).map: *.gist;
@pairs.push("...") if self.elems > 100;
self.^name ~ '.new((' ~ @pairs.join(', ') ~ '))'
}

multi method perl(Map:D \SELF: --> Str:D) {

0 comments on commit b4d114a

Please sign in to comment.
You can’t perform that action at this time.