summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Leach <richardleach@users.noreply.github.com>2023-01-13 18:04:38 +0000
committerYves Orton <demerphq@gmail.com>2023-01-13 20:34:06 +0100
commit3bbe14f5ab0067b7ce4357aaa1fc3ecfc48afac6 (patch)
tree4bfb69f0c91c991b09071da1e6df99141d8f60fd
parent61e2c0af14d6f848fd8f2ca85beeeb8363365321 (diff)
downloadperl-3bbe14f5ab0067b7ce4357aaa1fc3ecfc48afac6.tar.gz
t/test.pl - assign caller() to separate vars in _where()
_where() is a heavily used, small subroutine within test.pl. It currently assigns all eleven of caller()'s return values to array elements, then uses only the second and third of these to construct a return string. This commit changes the assignment to use separate variables, which ends up being more efficient. Benchmarking suggests that _where() is about 30% faster as a result. The overhead of ok( ... ) calls is reduced by about 10%.
-rw-r--r--t/test.pl4
1 files changed, 2 insertions, 2 deletions
diff --git a/t/test.pl b/t/test.pl
index 2c4690834c..fdf7d594fa 100644
--- a/t/test.pl
+++ b/t/test.pl
@@ -274,8 +274,8 @@ sub _ok {
}
sub _where {
- my @caller = caller($Level);
- return "at $caller[1] line $caller[2]";
+ my (undef, $filename, $lineno) = caller($Level);
+ return "at $filename line $lineno";
}
# DON'T use this for matches. Use like() instead.