From: Karen Etheridge Date: Sat, 17 Sep 2022 18:00:38 +0000 (-0700) Subject: switch the order of the isa checks, for performance improvement X-Git-Tag: v1.004004~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=81fabeee84af8fa3bef787c79c9f452d60aa81c6;p=p5sagit%2FJSON-MaybeXS.git switch the order of the isa checks, for performance improvement JSON booleans are more likely to be a JSON::PP::Boolean, as that is the result of the true, false subs in all (current releases) of the three backends --- diff --git a/Changes b/Changes index 2a48d8d..e91750d 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,7 @@ Revision history for JSON-MaybeXS + - slight speed optimization for is_bool() + 1.004003 - 2020-11-13 - fix another test that fails when JSON::XS is installed, but below version 3.0 diff --git a/lib/JSON/MaybeXS.pm b/lib/JSON/MaybeXS.pm index 88dd2c5..86d0006 100644 --- a/lib/JSON/MaybeXS.pm +++ b/lib/JSON/MaybeXS.pm @@ -57,9 +57,9 @@ sub is_bool { die 'is_bool is not a method' if $_[1]; Scalar::Util::blessed($_[0]) - and ($_[0]->isa('JSON::XS::Boolean') + and ($_[0]->isa('JSON::PP::Boolean') or $_[0]->isa('Cpanel::JSON::XS::Boolean') - or $_[0]->isa('JSON::PP::Boolean')); + or $_[0]->isa('JSON::XS::Boolean')); } # (mostly) CopyPasta from JSON.pm version 2.90