From 8fcb24256a3027cbca7c100825eb3805586fe1e5 Mon Sep 17 00:00:00 2001 From: Richard Leach Date: Wed, 9 Feb 2022 21:53:55 +0000 Subject: Inlined newSV_type(SVt_NULL) leaner than non-inlined newSV(0) When a function outside of sv.c creates a SV via newSV(0): * There is a call to Perl_newSV * A SV head is uprooted and its flags set * A runtime check is made to effectively see if 0 > 0 * The new SV* is returned Replacing newSV(0) with newSV_type(SVt_NULL) should be more efficient, because (assuming there are SV heads to uproot), the only step is: * A SV head is uprooted and its flags set --- inline.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inline.h') diff --git a/inline.h b/inline.h index c5f0ee69b3..2bf98d815d 100644 --- a/inline.h +++ b/inline.h @@ -134,7 +134,7 @@ Perl_av_fetch_simple(pTHX_ AV *av, SSize_t key, I32 lval) assert(key > -1); if ( (key > AvFILLp(av)) || !AvARRAY(av)[key]) { - return lval ? av_store_simple(av,key,newSV(0)) : NULL; + return lval ? av_store_simple(av,key,newSV_type(SVt_NULL)) : NULL; } else { return &AvARRAY(av)[key]; } -- cgit v1.2.1