Skip to content

Commit

Permalink
Don't use named variables between internal methods
Browse files Browse the repository at this point in the history
There's no need, so why have the extra overhead of an optional named
parameter, when a obligatory positional will do.
  • Loading branch information
lizmat committed Apr 17, 2020
1 parent 2fb7198 commit 9275057
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
14 changes: 9 additions & 5 deletions src/core.c/Rakudo/Iterator.pm6
Expand Up @@ -1481,8 +1481,8 @@ class Rakudo::Iterator {
}
}
}
method CStyleLoop(&body,&cond,&afterwards,:$label) {
CStyleLoop.new(&body,&cond,&afterwards,$label)
method CStyleLoop(&body, &cond, &afterwards, $label) {
CStyleLoop.new(&body, &cond, &afterwards, $label)
}

my role DelegateCountOnly[\iter] does PredictiveIterator {
Expand Down Expand Up @@ -2383,7 +2383,7 @@ class Rakudo::Iterator {

method is-lazy(--> True) { }
}
method Loop(&body,:$label) { Loop.new(&body,$label) }
method Loop(&body, $label) { Loop.new(&body, $label) }

# An often occurring use of the Mappy role to generate all of the
# keys of a Map / Hash. Takes a Map / Hash as the only parameter.
Expand Down Expand Up @@ -3052,7 +3052,9 @@ class Rakudo::Iterator {
}
}
}
method RepeatLoop(&body, &cond, :$label) { RepeatLoop.new(&body,&cond,$label) }
method RepeatLoop(&body, &cond, $label) {
RepeatLoop.new(&body, &cond, $label)
}

# Return an iterator that rotorizes the given iterator with the
# given cycle. If the cycle is a Cool, then it is assumed to
Expand Down Expand Up @@ -3995,7 +3997,9 @@ class Rakudo::Iterator {
}

}
method WhileLoop(&body, &cond, :$label) { WhileLoop.new(&body,&cond,$label) }
method WhileLoop(&body, &cond, $label) {
WhileLoop.new(&body, &cond, $label)
}

# Return an iterator that will zip the given iterables (with &[,])
# Basically the functionality of @a Z @b
Expand Down
14 changes: 7 additions & 7 deletions src/core.c/Seq.pm6
Expand Up @@ -124,21 +124,21 @@ my class Seq is Cool does Iterable does Sequence {
)
}

# This method is mainly called from Actions.nqp
proto method from-loop(|) {*}
multi method from-loop(&body, :$label) {
Seq.new(Rakudo::Iterator.Loop(&body, :$label))
Seq.new: Rakudo::Iterator.Loop(&body, $label)
}
multi method from-loop(&body, &cond, :$repeat!, :$label) {
Seq.new($repeat
?? Rakudo::Iterator.RepeatLoop(&body, &cond, :$label)
!! Rakudo::Iterator.WhileLoop(&body, &cond, :$label)
)
Seq.new: $repeat
?? Rakudo::Iterator.RepeatLoop(&body, &cond, $label)
!! Rakudo::Iterator.WhileLoop(&body, &cond, $label)
}
multi method from-loop(&body, &cond, :$label) {
Seq.new(Rakudo::Iterator.WhileLoop(&body, &cond, :$label))
Seq.new: Rakudo::Iterator.WhileLoop(&body, &cond, $label)
}
multi method from-loop(&body, &cond, &afterwards, :$label) {
Seq.new(Rakudo::Iterator.CStyleLoop(&body, &cond, &afterwards, :$label))
Seq.new: Rakudo::Iterator.CStyleLoop(&body, &cond, &afterwards, $label)
}

multi method ACCEPTS(Seq:D: Iterable:D \iterable --> Bool:D) {
Expand Down

0 comments on commit 9275057

Please sign in to comment.