diff options
author | Nicholas Clark <nick@ccl4.org> | 2010-11-01 13:08:07 +0000 |
---|---|---|
committer | Nicholas Clark <nick@ccl4.org> | 2010-11-01 13:08:07 +0000 |
commit | cbc736f3c4431a04bf792982d02220182ea6667f (patch) | |
tree | c05cff37d539a79fb60e9264e79eca4f21e478a7 /dist | |
parent | a4aabc83671e88f2620edff3736b7472cc0523d3 (diff) | |
download | perl-cbc736f3c4431a04bf792982d02220182ea6667f.tar.gz |
Refactor Storable::{net_,}pstore to return undef/true, instead of 1 or 0.
This allows their only caller, Storable::_store(), to be simplified, as $ret
will now have the correct values for its documented interface.
Also, replace C<$ret = undef> with C<undef $ret>, as the latter is equivalent,
but uses 1 fewer op.
Diffstat (limited to 'dist')
-rw-r--r-- | dist/Storable/Storable.pm | 6 | ||||
-rw-r--r-- | dist/Storable/Storable.xs | 11 |
2 files changed, 8 insertions, 9 deletions
diff --git a/dist/Storable/Storable.pm b/dist/Storable/Storable.pm index 70557faf5a..ddb9c82f6e 100644 --- a/dist/Storable/Storable.pm +++ b/dist/Storable/Storable.pm @@ -268,12 +268,12 @@ sub _store { # if close fails, it returns false, $ret is altered, *that* is (also) # false, so the () expression is false, !() is true, and the block is # entered. - if (!(close(FILE) or $ret = undef) || $@) { + if (!(close(FILE) or undef $ret) || $@) { unlink($file) or warn "Can't unlink $file: $!\n"; } logcroak $@ if $@ =~ s/\.?\n$/,/; $@ = $da; - return $ret ? $ret : undef; + return $ret; } # @@ -312,7 +312,7 @@ sub _store_fd { logcroak $@ if $@ =~ s/\.?\n$/,/; local $\; print $file ''; # Autoflush the file if wanted $@ = $da; - return $ret ? $ret : undef; + return $ret; } # diff --git a/dist/Storable/Storable.xs b/dist/Storable/Storable.xs index 2853657880..bbe15f4a2f 100644 --- a/dist/Storable/Storable.xs +++ b/dist/Storable/Storable.xs @@ -6354,23 +6354,22 @@ init_perinterp() # pstore # # Store the transitive data closure of given object to disk. -# Returns 0 on error, a true value otherwise. +# Returns undef on error, a true value otherwise. # net_pstore # # Same as pstore(), but network order is used for integers and doubles are # emitted as strings. -int +void pstore(f,obj) OutputStream f SV * obj ALIAS: net_pstore = 1 - CODE: - RETVAL = do_store(aTHX_ f, obj, 0, ix, (SV **)0); - OUTPUT: - RETVAL + PPCODE: + ST(0) = do_store(aTHX_ f, obj, 0, ix, (SV **)0) ? &PL_sv_yes : &PL_sv_undef; + XSRETURN(1); # mstore # |