This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
sv_clear only test for SvOBJECT on >= MG
authorDavid Mitchell <davem@iabyn.com>
Thu, 19 May 2011 14:51:45 +0000 (15:51 +0100)
committerDavid Mitchell <davem@iabyn.com>
Thu, 19 May 2011 21:01:02 +0000 (22:01 +0100)
micro-optimisation

sv.c

diff --git a/sv.c b/sv.c
index 6efcc8f..b55d49d 100644 (file)
--- a/sv.c
+++ b/sv.c
@@ -6049,10 +6049,12 @@ Perl_sv_clear(pTHX_ SV *const orig_sv)
            goto free_head;
        }
 
-       if (SvOBJECT(sv)) {
-           if (!curse(sv, 1)) goto get_next_sv;
-       }
+       assert(!SvOBJECT(sv) || type >= SVt_PVMG); /* objs are always >= MG */
+
        if (type >= SVt_PVMG) {
+           if (SvOBJECT(sv)) {
+               if (!curse(sv, 1)) goto get_next_sv;
+           }
            /* Free back-references before magic, in case the magic calls
             * Perl code that has weak references to sv. */
            if (type == SVt_PVHV) {