Skip to content

Commit

Permalink
improve Mojo::JSON performance slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Feb 1, 2016
1 parent 3e09394 commit ed9e5f8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions Changes
@@ -1,5 +1,6 @@

6.44 2016-02-02
- Improved Mojo::JSON performance slightly.

6.43 2016-02-01
- Removed client_close and server_close methods from Mojo::Transaction.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/JSON.pm
@@ -1,7 +1,6 @@
package Mojo::JSON;
use Mojo::Base -strict;

use B;
use Carp 'croak';
use Exporter 'import';
use JSON::PP ();
Expand Down Expand Up @@ -250,8 +249,9 @@ sub _encode_value {
return 'null' unless defined $value;

# Number
no warnings 'numeric';
return $value
if B::svref_2object(\$value)->FLAGS & (B::SVp_IOK | B::SVp_NOK)
if length((my $dummy = '') & $value)
&& 0 + $value eq $value
&& $value * 0 == 0;

Expand Down

0 comments on commit ed9e5f8

Please sign in to comment.