Skip to content

Commit

Permalink
- Minor performance improvement for the Bool type
Browse files Browse the repository at this point in the history
  • Loading branch information
trizen committed Jul 31, 2015
1 parent 71ba3ae commit b111db6
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/Sidef/Types/Bool/Bool.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,18 @@ package Sidef::Types::Bool::Bool {
);

{
my %bool = (
true => (bless \(my $t = 1), __PACKAGE__),
false => (bless \(my $f = 0), __PACKAGE__),
);
my $true = (bless \(my $t = 1), __PACKAGE__);
my $false = (bless \(my $f = 0), __PACKAGE__);

sub new {
my (undef, $bool) = @_;
$bool{$bool ? 'true' : 'false'};
$bool ? $true : $false;
}

*call = \&new;

sub true { $bool{true} }
sub false { $bool{false} }
sub true { $true }
sub false { $false }
}

sub get_value { ${$_[0]} }
Expand Down

0 comments on commit b111db6

Please sign in to comment.