Merge Storable::{,net_}pstore and Storable::{,net_}mstore using ALIAS.
authorNicholas Clark <nick@ccl4.org>
Sun, 31 Oct 2010 20:32:20 +0000 (20:32 +0000)
committerNicholas Clark <nick@ccl4.org>
Sun, 31 Oct 2010 20:35:54 +0000 (20:35 +0000)
Remove the static functions {,net}[mp]store(), which were trivial wrappers
around do_store(). Instead call do_store() directly, using the ALIAS index
as the flag. Less code.

On this platform, this reduces the object code by over 1K. (Over 1%)

dist/Storable/Storable.pm
dist/Storable/Storable.xs

index 7627943..f93d300 100644 (file)
@@ -23,7 +23,7 @@ use AutoLoader;
 use FileHandle;
 use vars qw($canonical $forgive_me $VERSION);
 
-$VERSION = '2.22';
+$VERSION = '2.23';
 *AUTOLOAD = \&AutoLoader::AUTOLOAD;            # Grrr...
 
 #
index 8d8b629..7ede03a 100644 (file)
@@ -3841,31 +3841,6 @@ static int do_store(
        return status == 0;
 }
 
-/*
- * pstore
- *
- * Store the transitive data closure of given object to disk.
- * Returns 0 on error, a true value otherwise.
- */
-static int pstore(pTHX_ PerlIO *f, SV *sv)
-{
-       TRACEME(("pstore"));
-       return do_store(aTHX_ f, sv, 0, FALSE, (SV**) 0);
-
-}
-
-/*
- * net_pstore
- *
- * Same as pstore(), but network order is used for integers and doubles are
- * emitted as strings.
- */
-static int net_pstore(pTHX_ PerlIO *f, SV *sv)
-{
-       TRACEME(("net_pstore"));
-       return do_store(aTHX_ f, sv, 0, TRUE, (SV**) 0);
-}
-
 /***
  *** Memory stores.
  ***/
@@ -3882,42 +3857,6 @@ static SV *mbuf2sv(pTHX)
        return newSVpv(mbase, MBUF_SIZE());
 }
 
-/*
- * mstore
- *
- * Store the transitive data closure of given object to memory.
- * Returns undef on error, a scalar value containing the data otherwise.
- */
-static SV *mstore(pTHX_ SV *sv)
-{
-       SV *out;
-
-       TRACEME(("mstore"));
-
-       if (!do_store(aTHX_ (PerlIO*) 0, sv, 0, FALSE, &out))
-               return &PL_sv_undef;
-
-       return out;
-}
-
-/*
- * net_mstore
- *
- * Same as mstore(), but network order is used for integers and doubles are
- * emitted as strings.
- */
-static SV *net_mstore(pTHX_ SV *sv)
-{
-       SV *out;
-
-       TRACEME(("net_mstore"));
-
-       if (!do_store(aTHX_ (PerlIO*) 0, sv, 0, TRUE, &out))
-               return &PL_sv_undef;
-
-       return out;
-}
-
 /***
  *** Specific retrieve callbacks.
  ***/
@@ -6412,37 +6351,45 @@ init_perinterp()
  CODE:
   init_perinterp(aTHX);
 
+# pstore
+#
+# Store the transitive data closure of given object to disk.
+# Returns 0 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
 pstore(f,obj)
 OutputStream   f
 SV *   obj
+ ALIAS:
+  net_pstore = 1
  CODE:
-  RETVAL = pstore(aTHX_ f, obj);
+  RETVAL = do_store(aTHX_ f, obj, 0, ix, (SV **)0);
  OUTPUT:
   RETVAL
 
-int
-net_pstore(f,obj)
-OutputStream   f
-SV *   obj
- CODE:
-  RETVAL = net_pstore(aTHX_ f, obj);
- OUTPUT:
-  RETVAL
+# mstore
+#
+# Store the transitive data closure of given object to memory.
+# Returns undef on error, a scalar value containing the data otherwise.
 
-SV *
-mstore(obj)
-SV *   obj
- CODE:
-  RETVAL = mstore(aTHX_ obj);
- OUTPUT:
-  RETVAL
+# net_mstore
+#
+# Same as mstore(), but network order is used for integers and doubles are
+# emitted as strings.
 
 SV *
-net_mstore(obj)
+mstore(obj)
 SV *   obj
+ ALIAS:
+  net_mstore = 1
  CODE:
-  RETVAL = net_mstore(aTHX_ obj);
+  if (!do_store(aTHX_ (PerlIO*) 0, obj, 0, ix, &RETVAL))
+    RETVAL = &PL_sv_undef;
  OUTPUT:
   RETVAL