Skip to content

Commit

Permalink
Abstract check for Range being inside native integer range
Browse files Browse the repository at this point in the history
  • Loading branch information
lizmat committed Jul 17, 2018
1 parent 6ad096c commit 806752f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/core/Range.pm6
Expand Up @@ -82,6 +82,10 @@ my class Range is Cool does Iterable does Positional {
method infinite() { nqp::p6bool($!infinite) }
method is-int() { nqp::p6bool($!is-int) }

method !IS-NATIVE-INT() {
$!is-int && nqp::not_i(nqp::isbig_I($!min) || nqp::isbig_I($!max))
}

multi method WHICH (Range:D:) {
(nqp::istype(self.WHAT,Range) ?? 'Range|' !! (self.^name ~ '|'))
~ $!min
Expand Down Expand Up @@ -231,9 +235,7 @@ my class Range is Cool does Iterable does Positional {

method !reverse-iterator() {
# can use native ints
if $!is-int
&& !nqp::isbig_I($!min)
&& !nqp::isbig_I($!max) {
if self!IS-NATIVE-INT() {
class :: does Iterator {
has int $!i;
has int $!n;
Expand Down

0 comments on commit 806752f

Please sign in to comment.