From: Vincent Pit Date: Mon, 3 Nov 2008 09:14:33 +0000 (+0100) Subject: Replace tail recursion in _wrap() by a while loop X-Git-Tag: v0.09~13 X-Git-Url: http://git.vpit.fr/?p=perl%2Fmodules%2FSub-Prototype-Util.git;a=commitdiff_plain;h=06a00e8349c4f0c7b7388af0dbfcd562721e8d43 Replace tail recursion in _wrap() by a while loop --- diff --git a/lib/Sub/Prototype/Util.pm b/lib/Sub/Prototype/Util.pm index a92647f..d549a1c 100644 --- a/lib/Sub/Prototype/Util.pm +++ b/lib/Sub/Prototype/Util.pm @@ -139,9 +139,8 @@ For example, this allows you to recall into C and C 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 {