Skip to content

Commit

Permalink
S_mro_get_linear_isa_c3() now uses sv_inc_nomg().
Browse files Browse the repository at this point in the history
Previously it was coding the increment "longhand", to avoid bugs in 5.6.x.
However, this XS code is now exclusively in the core, and 5.6.x is long
dead, so there's no need to work around it.

The "longhand" code might *seem* to be more efficient (due to inlining some
logic) but it still required at least one call to a function in sv.c
(so no real change in generated code size) and that call was for the
increment 0 => 1, so likely called a lot, so no significant change in total
calls made.
  • Loading branch information
nwc10 committed Aug 23, 2021
1 parent 451833e commit ded520d
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
2 changes: 1 addition & 1 deletion ext/mro/mro.pm
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use warnings;

# mro.pm versions < 1.00 reserved for MRO::Compat
# for partial back-compat to 5.[68].x
our $VERSION = '1.25_001';
our $VERSION = '1.26';

require XSLoader;
XSLoader::load('mro');
Expand Down
11 changes: 1 addition & 10 deletions ext/mro/mro.xs
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,7 @@ S_mro_get_linear_isa_c3(pTHX_ HV* stash, U32 level)
*/
HE* const he = hv_fetch_ent(tails, seqitem, 1, 0);
if(he) {
SV* const val = HeVAL(he);
/* For 5.8.0 and later, sv_inc() with increment undef to
an IV of 1, which is what we want for a newly created
entry. However, for 5.6.x it will become an NV of
1.0, which confuses the SvIVX() checks above. */
if(SvIOK(val)) {
SvIV_set(val, SvIVX(val) + 1);
} else {
sv_setiv(val, 1);
}
sv_inc_nomg(HeVAL(he));
}
}
}
Expand Down

0 comments on commit ded520d

Please sign in to comment.