From: Matt S Trout Date: Thu, 3 Jan 2013 22:31:35 +0000 (-0800) Subject: bypass new() in _hsv_dot and switch to blessed() to avoid calling our own ref() X-Git-Tag: v1.000002~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=91a964778ba8e61c05cab7b11db64d6366d6529d;p=scpubgit%2FHTML-String.git bypass new() in _hsv_dot and switch to blessed() to avoid calling our own ref() --- diff --git a/Changes b/Changes index 887d361..f64ca88 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,5 @@ + - Optimise _hsv_dot since it gets called heavily by HTML::String::TT + 1.000001 - 2013-01-03 - Localize $@ in isa and can in case of modules that mishandle eval {} - Support for single quotes (' to ') diff --git a/lib/HTML/String/Value.pm b/lib/HTML/String/Value.pm index 5adf3a9..1eedc5e 100644 --- a/lib/HTML/String/Value.pm +++ b/lib/HTML/String/Value.pm @@ -3,6 +3,7 @@ package HTML::String::Value; use strictures 1; use UNIVERSAL::ref; use Safe::Isa; +use Scalar::Util qw(blessed); use Data::Munge; use overload @@ -14,7 +15,10 @@ use overload ; sub new { - if (ref($_[0])) { my $c = shift; return $c->_hsv_unescaped_string->new(@_) } + if (blessed($_[0])) { + my $c = shift; + return $c->_hsv_unescaped_string->new(@_); + } my ($class, @raw_parts) = @_; my $opts = (ref($raw_parts[-1]) eq 'HASH') ? pop(@raw_parts) : {}; @@ -87,7 +91,7 @@ sub _hsv_dot { push @parts, @new_parts; } - return ref($self)->new(@parts, { ignore => $self->{ignore} }); + return bless({ %$self, parts => \@parts }, blessed($self)); } sub _hsv_is_true {