This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make HvENAME** macros smaller and more efficient
authorH.Merijn Brand <h.m.brand@xs4all.nl>
Mon, 17 Oct 2011 15:15:32 +0000 (17:15 +0200)
committerH.Merijn Brand <h.m.brand@xs4all.nl>
Mon, 17 Oct 2011 15:15:32 +0000 (17:15 +0200)
Brian's comments:
if xhv_name_count == 1, HvENAME_HEK_NN returns null.
So there's no need to use that macro twice. Just check for -1

The real need to make these smaller is the fact that some precompilers
(e.g. HP-UX 10.20) cannot cope with the size these have grown to.  The
precompiler has since got an option (-Hnnn) to increase the macrospace
but that option never made it to these old compilers.

Signed-off-by: H.Merijn Brand <h.m.brand@xs4all.nl>
hv.h

diff --git a/hv.h b/hv.h
index c38b493..64eb511 100644 (file)
--- a/hv.h
+++ b/hv.h
@@ -308,13 +308,13 @@ C<SV*>.
 #define HvENAME_HEK(hv) \
        (SvOOK(hv) && HvAUX(hv)->xhv_name_u.xhvnameu_name ? HvENAME_HEK_NN(hv) : NULL)
 #define HvENAME_get(hv) \
-       ((SvOOK(hv) && HvAUX(hv)->xhv_name_u.xhvnameu_name && HvENAME_HEK_NN(hv)) \
+   ((SvOOK(hv) && HvAUX(hv)->xhv_name_u.xhvnameu_name && HvAUX(hv)->xhv_name_count != -1) \
                         ? HEK_KEY(HvENAME_HEK_NN(hv)) : NULL)
 #define HvENAMELEN_get(hv) \
-       ((SvOOK(hv) && HvAUX(hv)->xhv_name_u.xhvnameu_name && HvENAME_HEK_NN(hv)) \
+   ((SvOOK(hv) && HvAUX(hv)->xhv_name_u.xhvnameu_name && HvAUX(hv)->xhv_name_count != -1) \
                                 ? HEK_LEN(HvENAME_HEK_NN(hv)) : 0)
 #define HvENAMEUTF8(hv) \
-       ((SvOOK(hv) && HvAUX(hv)->xhv_name_u.xhvnameu_name && HvENAME_HEK_NN(hv)) \
+   ((SvOOK(hv) && HvAUX(hv)->xhv_name_u.xhvnameu_name && HvAUX(hv)->xhv_name_count != -1) \
                                 ? HEK_UTF8(HvENAME_HEK_NN(hv)) : 0)
 
 /* the number of keys (including any placeholders) */