if ($trace && some_other_condition()) {
$trace->as_string;
}
this code looks as if $trace->as_string doesn't get called if some_other_condition() is false, or just once if the condition is true. But actually, the first if ($trace) triggers as_string due to the string overloading, and how perl's overload automatically uses the string value for boolean check. As a result, $trace->as_string is called one extra time which could cause some slow down in the app when the stacktrace is huge.
Consider adding bool => sub { 1 } to the overload list to avoid this. I've worked around in the caller code to change the if statement to if (ref $trace) for now.
re https://github.com/plack/Plack/pull/697
this code looks as if
$trace->as_string
doesn't get called ifsome_other_condition()
is false, or just once if the condition is true. But actually, the firstif ($trace)
triggersas_string
due to the string overloading, and how perl's overload automatically uses the string value for boolean check. As a result,$trace->as_string
is called one extra time which could cause some slow down in the app when the stacktrace is huge.Consider adding
bool => sub { 1 }
to the overload list to avoid this. I've worked around in the caller code to change the if statement toif (ref $trace)
for now.