summaryrefslogtreecommitdiff
path: root/av.c
diff options
context:
space:
mode:
authorDaniel Dragan <bulk88@hotmail.com>2014-03-13 02:51:51 -0400
committerTony Cook <tony@develop-help.com>2014-05-28 11:45:22 +1000
commit725995b4682495a83cf4d8d7eeb037b9cb950d65 (patch)
tree8e2ecdc043a88f1ef67609635003a95ab481a49e /av.c
parentc13fd1a2c58fd514793206a1d4659a47866a259a (diff)
downloadperl-725995b4682495a83cf4d8d7eeb037b9cb950d65.tar.gz
refactor av_delete
Some bad code generation/bad optimization from VC caused me to clean this up. Dont write AvARRAY(av)[key] = NULL twice. It appears in 2 branches just as written VC asm wise. Don't call sv_2mortal on a NULL SV*. It works but less efficient. On VC2008 x64 -O1 this func dropped from 0x208 to 0x202 bytes of machine code after this patch.
Diffstat (limited to 'av.c')
-rw-r--r--av.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/av.c b/av.c
index 5ef3a557d7..c08d2c2d3f 100644
--- a/av.c
+++ b/av.c
@@ -889,23 +889,23 @@ Perl_av_delete(pTHX_ AV *av, SSize_t key, I32 flags)
if (!AvREAL(av) && AvREIFY(av))
av_reify(av);
sv = AvARRAY(av)[key];
+ AvARRAY(av)[key] = NULL;
if (key == AvFILLp(av)) {
- AvARRAY(av)[key] = NULL;
do {
AvFILLp(av)--;
} while (--key >= 0 && !AvARRAY(av)[key]);
}
- else
- AvARRAY(av)[key] = NULL;
if (SvSMAGICAL(av))
mg_set(MUTABLE_SV(av));
}
- if (flags & G_DISCARD) {
- SvREFCNT_dec(sv);
- sv = NULL;
+ if(sv != NULL) {
+ if (flags & G_DISCARD) {
+ SvREFCNT_dec_NN(sv);
+ return NULL;
+ }
+ else if (AvREAL(av))
+ sv_2mortal(sv);
}
- else if (AvREAL(av))
- sv = sv_2mortal(sv);
return sv;
}