Skip to content

Commit 5cf6593

Browse files
committed
Perl_newSVpvn_share - minor changes to help the compiler.
This commit: * swaps `SvLEN_set(sv, 0)` for an assertion of this default value. * Moves `SvCUR_set` and the (now-combined) flag assignment before the call to `sharepvn`, giving the compiler a better chance to combine them with the initialization (likely) inlined from `newSV_type(SVt_PV)`.
1 parent fb1dc98 commit 5cf6593

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

sv.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10379,13 +10379,11 @@ Perl_newSVpvn_share(pTHX_ const char *src, I32 len, U32 hash)
1037910379
sv = newSV_type(SVt_PV);
1038010380
/* The logic for this is inlined in S_mro_get_linear_isa_dfs(), so if it
1038110381
changes here, update it there too. */
10382-
SvPV_set(sv, sharepvn(src, is_utf8?-len:len, hash));
10382+
SvFLAGS(sv) |= SVf_POK | SVp_POK | SVf_IsCOW |
10383+
(is_utf8 ? SVf_UTF8 : 0);
1038310384
SvCUR_set(sv, len);
10384-
SvLEN_set(sv, 0);
10385-
SvIsCOW_on(sv);
10386-
SvPOK_on(sv);
10387-
if (is_utf8)
10388-
SvUTF8_on(sv);
10385+
assert(SvLEN(sv) ==0);
10386+
SvPV_set(sv, sharepvn(src, is_utf8?-len:len, hash));
1038910387
return sv;
1039010388
}
1039110389

0 commit comments

Comments
 (0)