Skip to content

Commit

Permalink
Reduction spree in Str
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Aug 10, 2018
1 parent 62cb070 commit 7b1d16f
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/core/Str.pm6
Expand Up @@ -145,11 +145,12 @@ my class Str does Stringy { # declared in BOOTSTRAP
proto method ends-with(|) {*}
multi method ends-with(Str:D: Cool:D $suffix) {self.ends-with: $suffix.Str}
multi method ends-with(Str:D: Str:D $suffix) {
nqp::p6bool(nqp::eqat(
$!value,
nqp::getattr($suffix,Str,'$!value'),
nqp::chars($!value) - nqp::chars(nqp::getattr($suffix,Str,'$!value'))
))
my \value := nqp::getattr($suffix,Str,'$!value');
nqp::p6bool(
nqp::eqat(
$!value,value,nqp::sub_i(nqp::chars($!value),nqp::chars(value))
)
)
}

# TODO Use coercer in 1 candidate when RT131014
Expand Down

0 comments on commit 7b1d16f

Please sign in to comment.