Since we already have a check further down to see whether a string
begins with an identifier or sign, and since looks_like_number
was added for strings representing negative numbers, move the
looks_like_number down to where we already know the string
begins with '-'.
This is a micro-optimisation, but it also makes the code more
straightforward (to me at least).
This happens to let magical integers-as-strings fall down to code that
they used not to reach, so that has to change to account.
{
SV * const sv = TOPs;
- if( !SvNIOK( sv ) && looks_like_number( sv ) ){
- SvIV_please_nomg( sv );
- }
-
if (SvIOK(sv) || (SvGMAGICAL(sv) && SvIOKp(sv))) {
/* It's publicly an integer */
oops_its_an_int:
sv_setpvs(TARG, "-");
sv_catsv(TARG, sv);
}
- else if (*s == '+' || *s == '-') {
+ else if (*s == '+' || (*s == '-' && !looks_like_number(sv))) {
sv_setsv_nomg(TARG, sv);
*SvPV_force_nomg(TARG, len) = *s == '-' ? '+' : '-';
}
- else {
- SvIV_please_nomg(sv);
- if (SvIOK(sv))
+ else if (SvIV_please_nomg(sv))
goto oops_its_an_int;
+ else
sv_setnv(TARG, -SvNV_nomg(sv));
- }
SETTARG;
}
else