Skip to content

Commit

Permalink
Make a minor optimization to a bunch of STORE methods
Browse files Browse the repository at this point in the history
Same method of optimization as in
4bbe308.
  • Loading branch information
Kaiepi committed Mar 29, 2020
1 parent 4bbe308 commit a4fbbfa
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/core.c/Bag.pm6
Expand Up @@ -37,7 +37,7 @@ my class Bag does Baggy {
}

#--- interface methods
multi method STORE(Bag:D: *@pairs, :$INITIALIZE! --> Bag:D) {
multi method STORE(Bag:D: *@pairs, :INITIALIZE($)! --> Bag:D) {
(my \iterator := @pairs.iterator).is-lazy
?? Failure.new(
X::Cannot::Lazy.new(:action<initialize>,:what(self.^name))
Expand All @@ -46,7 +46,7 @@ my class Bag does Baggy {
nqp::create(Rakudo::Internals::IterationSet),iterator,self.keyof
))
}
multi method STORE(Bag:D: \objects, \values, :$INITIALIZE! --> Bag:D) {
multi method STORE(Bag:D: \objects, \values, :INITIALIZE($)! --> Bag:D) {
self.SET-SELF(
Rakudo::QuantHash.ADD-OBJECTS-VALUES-TO-BAG(
nqp::create(Rakudo::Internals::IterationSet),
Expand Down
2 changes: 1 addition & 1 deletion src/core.c/List.pm6
Expand Up @@ -759,7 +759,7 @@ my class List does Iterable does Positional { # declared in BOOTSTRAP
# Store in List targets containers with in the list. This handles list
# assignments, like ($a, $b) = foo().
proto method STORE(List:D: |) {*}
multi method STORE(List:D: Iterable:D \iterable, :$INITIALIZE! --> List:D) {
multi method STORE(List:D: Iterable:D \iterable, :INITIALIZE($)! --> List:D) {
my \buffer := nqp::create(IterationBuffer);
iterable.iterator.push-all(buffer);
nqp::p6bindattrinvres(self,List,'$!reified',buffer)
Expand Down
14 changes: 7 additions & 7 deletions src/core.c/Map.pm6
Expand Up @@ -461,7 +461,7 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP
}

proto method STORE(Map:D: |) {*}
multi method STORE(Map:D: Map:D \map, :$INITIALIZE!, :$DECONT! --> Map:D) {
multi method STORE(Map:D: Map:D \map, :INITIALIZE($)!, :DECONT($)! --> Map:D) {
nqp::if(
nqp::eqaddr(map.keyof,Str(Any)), # is it not an Object Hash?
nqp::if(
Expand All @@ -476,7 +476,7 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP
self!STORE_MAP_FROM_OBJECT_HASH_DECONT(map)
)
}
multi method STORE(Map:D: Map:D \map, :$INITIALIZE! --> Map:D) {
multi method STORE(Map:D: Map:D \map, :INITIALIZE($)! --> Map:D) {
nqp::if(
nqp::eqaddr(map.keyof,Str(Any)), # is it not an Object Hash?
nqp::if(
Expand All @@ -491,19 +491,19 @@ my class Map does Iterable does Associative { # declared in BOOTSTRAP
self!STORE_MAP_FROM_OBJECT_HASH(map)
)
}
multi method STORE(Map:D: Iterator:D \iter, :$INITIALIZE!, :$DECONT! --> Map:D) {
multi method STORE(Map:D: Iterator:D \iter, :INITIALIZE($)!, :DECONT($)! --> Map:D) {
self!STORE_MAP_FROM_ITERATOR_DECONT(iter)
}
multi method STORE(Map:D: Iterator:D \iter, :$INITIALIZE! --> Map:D) {
multi method STORE(Map:D: Iterator:D \iter, :INITIALIZE($)! --> Map:D) {
self!STORE_MAP_FROM_ITERATOR(iter)
}
multi method STORE(Map:D: \to_store, :$INITIALIZE!, :$DECONT! --> Map:D) {
multi method STORE(Map:D: \to_store, :INITIALIZE($)!, :DECONT($)! --> Map:D) {
self!STORE_MAP_FROM_ITERATOR_DECONT(to_store.iterator)
}
multi method STORE(Map:D: \to_store, :$INITIALIZE! --> Map:D) {
multi method STORE(Map:D: \to_store, :INITIALIZE($)! --> Map:D) {
self!STORE_MAP_FROM_ITERATOR(to_store.iterator)
}
multi method STORE(Map:D: \keys, \values, :$INITIALIZE! --> Map:D) {
multi method STORE(Map:D: \keys, \values, :INITIALIZE($)! --> Map:D) {
my \iterkeys := keys.iterator;
my \itervalues := values.iterator;
my \storage := $!storage := nqp::hash;
Expand Down
4 changes: 2 additions & 2 deletions src/core.c/Set.pm6
Expand Up @@ -96,7 +96,7 @@ my class Set does Setty {
multi method Mixy (Set:D:) { self.Mix }

#--- interface methods
multi method STORE(Set:D: *@pairs, :$INITIALIZE! --> Set:D) {
multi method STORE(Set:D: *@pairs, :INITIALIZE($)! --> Set:D) {
(my \iterator := @pairs.iterator).is-lazy
?? Failure.new(
X::Cannot::Lazy.new(:action<initialize>,:what(self.^name)))
Expand All @@ -106,7 +106,7 @@ my class Set does Setty {
self.keyof
))
}
multi method STORE(Set:D: \objects, \bools, :$INITIALIZE! --> Set:D) {
multi method STORE(Set:D: \objects, \bools, :INITIALIZE($)! --> Set:D) {
self.SET-SELF(
Rakudo::QuantHash.ADD-OBJECTS-VALUES-TO-SET(
nqp::create(Rakudo::Internals::IterationSet),
Expand Down

0 comments on commit a4fbbfa

Please sign in to comment.