# New Ticket Created by  Gilbert R. Roehrbein 
# Please include the string:  [perl #82312]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=82312 >


fixes the problem which you encounter when you try to evaluate
+(23..2300000000)

~ payload


>From b5d95340a193df9af8ccb185c33ef4177a7ab527 Mon Sep 17 00:00:00 2001

From: payload <payl...@lavabit.com>

Date: Sun, 16 Jan 2011 19:33:04 +0100

Subject: [PATCH] optimized Range for getting its size if its a numeric range



---

 src/core/Range.pm |   10 ++++++++++

 1 files changed, 10 insertions(+), 0 deletions(-)



diff --git a/src/core/Range.pm b/src/core/Range.pm

index fc1395b..8a07b53 100644

--- a/src/core/Range.pm

+++ b/src/core/Range.pm

@@ -103,6 +103,16 @@ class Range is Iterable does Positional {

     multi method roll(Whatever) {

         self.roll(Inf);

     }

+    

+    # to optimize the calculation of the size of a big range

+    # +(42..$big) doesnt take too much time now

+    multi method Numeric () {

+        nextsame unless $.max ~~ Numeric and $.min ~~ Numeric;

+        my $lo := $.min + $.excludes_min;

+        my $hi := $.max - $.excludes_max;

+        return 0 if $hi < $lo;

+        return ($hi - $lo + 1).floor;

+    }

 }

 

 

-- 

1.7.1



Attachment: signature.asc
Description: PGP signature

Reply via email to