]> git.vpit.fr Git - perl/modules/Sub-Prototype-Util.git/blobdiff - lib/Sub/Prototype/Util.pm
Replace tail recursion in _wrap() by a while loop
[perl/modules/Sub-Prototype-Util.git] / lib / Sub / Prototype / Util.pm
index a92647f6a4d224985ff72ac11dea3fd75ed980ca..d549a1cc992e8ea86ceac04a35f89d11a7207098 100644 (file)
@@ -139,9 +139,8 @@ For example, this allows you to recall into C<CORE::grep> and C<CORE::map> by us
 
 sub _wrap {
  my ($name, $proto, $i, $args, $cr, $opts) = @_;
if ($proto =~ /(\\?)(\[[^\]]+\]|[^\];])(.*)/g) {
while ($proto =~ s/(\\?)(\[[^\]]+\]|[^\];])//) {
   my ($ref, $p) = ($1, $2);
-  $proto = $3;
   $p = $1 if $p =~ /^\[([^\]]+)\]/;
   my $cur = '$_[' . $i . ']';
   if ($ref) {
@@ -176,11 +175,10 @@ sub _wrap {
   } else {
    $args .= $cur . ', ';
   }
-  return _wrap($name, $proto, ($i + 1), $args, $cr, $opts);
- } else {
-  $args =~ s/,\s*$//;
-  return $name . '(' . $args . ')';
+  ++$i;
  }
+ $args =~ s/,\s*$//;
+ return $name . '(' . $args . ')';
 }
 
 sub _check_name {