Repository navigation
Commit 75acd14
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);1 parent 4f16878 commit 75acd14
8 files changed
Lines changed: 525 additions & 370 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5569 | 5569 | | |
5570 | 5570 | | |
5571 | 5571 | | |
| 5572 | + | |
5572 | 5573 | | |
5573 | 5574 | | |
5574 | 5575 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1519 | 1519 | | |
1520 | 1520 | | |
1521 | 1521 | | |
1522 | | - | |
| 1522 | + | |
1523 | 1523 | | |
1524 | 1524 | | |
1525 | 1525 | | |
| |||
3171 | 3171 | | |
3172 | 3172 | | |
3173 | 3173 | | |
3174 | | - | |
| 3174 | + | |
3175 | 3175 | | |
3176 | 3176 | | |
3177 | 3177 | | |
| |||
3180 | 3180 | | |
3181 | 3181 | | |
3182 | 3182 | | |
3183 | | - | |
| 3183 | + | |
3184 | 3184 | | |
3185 | 3185 | | |
3186 | 3186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
881 | 881 | | |
882 | 882 | | |
883 | 883 | | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
884 | 887 | | |
885 | 888 | | |
886 | 889 | | |
| |||
1932 | 1935 | | |
1933 | 1936 | | |
1934 | 1937 | | |
1935 | | - | |
1936 | 1938 | | |
1937 | 1939 | | |
1938 | 1940 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1252 | 1252 | | |
1253 | 1253 | | |
1254 | 1254 | | |
1255 | | - | |
1256 | | - | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
1260 | | - | |
1261 | 1255 | | |
1262 | 1256 | | |
1263 | 1257 | | |
| |||
7160 | 7154 | | |
7161 | 7155 | | |
7162 | 7156 | | |
| 7157 | + | |
7163 | 7158 | | |
7164 | 7159 | | |
7165 | 7160 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2482 | 2482 | | |
2483 | 2483 | | |
2484 | 2484 | | |
2485 | | - | |
| 2485 | + | |
| 2486 | + | |
2486 | 2487 | | |
2487 | 2488 | | |
| 2489 | + | |
2488 | 2490 | | |
2489 | 2491 | | |
2490 | 2492 | | |
| |||
6461 | 6463 | | |
6462 | 6464 | | |
6463 | 6465 | | |
6464 | | - | |
| 6466 | + | |
6465 | 6467 | | |
6466 | 6468 | | |
6467 | 6469 | | |
| |||
0 commit comments