You're the benchmark master. ;-) One-time hit to require overload and then a single function call, or always check blessed, store the original package and bless twice?
Or how about this -- so we only use it if something else has loaded overload and the object is actually overloaded?
sub refaddr_pp { return if not ref $_[0]; if ( exists $INC{'overload.pm'} && overload::Overloaded($_[0]) ) { overload::StrVal($_[0]) =~ /0x(\w+)/; return hex $1; } else { return 0 + $_[0]; } }
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
In reply to Re^6: A Scalar::Util::refaddr Oddity
by xdg
in thread A Scalar::Util::refaddr Oddity
by Zaxo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |