Merge Hash::Util::FieldHash::_test_uvar_{get,set,same} using ALIAS.
authorNicholas Clark <nick@ccl4.org>
Mon, 25 Oct 2010 19:21:50 +0000 (20:21 +0100)
committerNicholas Clark <nick@ccl4.org>
Mon, 25 Oct 2010 19:22:37 +0000 (20:22 +0100)
On this platform it reduces the object code size by over 1K.
Ideally these test functions would not be in the installed code, but I can't
see an easy way to avoid this.

ext/Hash-Util-FieldHash/FieldHash.xs

index 60f5a6e..2c96646 100644 (file)
@@ -445,46 +445,19 @@ PPCODE:
 
 void
 _test_uvar_get(SV* svref, SV* countref)
+ALIAS:
+_test_uvar_get = 1
+_test_uvar_set = 2
+_test_uvar_same = 3
 CODE:
     if (SvROK(svref) && SvROK(countref)) {
         counter = SvRV(countref);
         sv_setiv(counter, 0);
         HUF_add_uvar_magic(
             SvRV(svref),
-            &HUF_inc_var,
-            NULL,
-            0,
-            SvRV(countref)
-        );
-    }
-
-void
-_test_uvar_set(SV* svref, SV* countref)
-CODE:
-    if (SvROK(svref) && SvROK(countref)) {
-        counter = SvRV(countref);
-        sv_setiv(counter, 0);
-        HUF_add_uvar_magic(
-            SvRV(svref),
-            NULL,
-            &HUF_inc_var,
-            0,
+            ix & 1 ? &HUF_inc_var : 0,
+            ix & 2 ? &HUF_inc_var : 0,
+           0,
             SvRV(countref)
         );
     }
-
-void
-_test_uvar_same(SV* svref, SV* countref)
-CODE:
-    if (SvROK(svref) && SvROK(countref)) {
-        counter = SvRV(countref);
-        sv_setiv(counter, 0);
-        HUF_add_uvar_magic(
-            SvRV(svref),
-            &HUF_inc_var,
-            &HUF_inc_var,
-            0,
-            NULL
-        );
-    }
-