diff options
author | Richard Leach <richardleach@users.noreply.github.com> | 2022-02-06 22:52:54 +0000 |
---|---|---|
committer | xenu <me@xenu.pl> | 2022-03-07 01:08:53 +0100 |
commit | 75acd14e43f2ffb698fc7032498f31095b56adb5 (patch) | |
tree | 2610d7b3965594afb1047abe39f389058152e87b /pp_hot.c | |
parent | 4f1687891150ddeda14ad7b0716032145bc69801 (diff) | |
download | perl-75acd14e43f2ffb698fc7032498f31095b56adb5.tar.gz |
Make newSV_type an inline function
When a new SV is created and upgraded to a type known at compile time,
uprooting a SV head and then using the general-purpose upgrade function
(sv_upgrade) is clunky. Specifically, while uprooting a SV head is
lightweight (assuming there are unused SVs), sv_upgrade is too big to be
inlined, contains many branches that can logically be resolved at compile
time for known start & end types, and the lookup of the correct
body_details struct may add CPU cycles.
This commit tries to address that by making newSV_type an inline function
and including only the parts of sv_upgrade needed to upgrade a SVt_NULL.
When the destination type is known at compile time, a decent compiler will
inline a call to newSV_type and use the type information to throw away all
the irrelevant parts of the sv_upgrade logic.
Because of the spread of type definitions across header files, it did not
seem possible to make the necessary changed inside sv.h, and so a new
header file (sv_inline.h) was created. For the inlined function to work
outside of sv.c, many definitions from that file were moved to sv_inline.h.
Finally, in order to also benefit from this change, existing code in sv.c
that does things like this:
SV* sv;
new_SV(sv);
sv_upgrade(sv, SVt_PV)
has been modified to read something like:
SV* sv = newSV_type(SVt_PV);
Diffstat (limited to 'pp_hot.c')
0 files changed, 0 insertions, 0 deletions