This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Perl_sv_vcatpvfn_flags: unify int arg fetching
There are two big blocks of code that do signed and unsigned 'get next int
arg' processing. Combine them (sort of).
Previously it was a bit like
case 'd':
case 'i':
base = 10;
if (vectorize)
uv = ...
else if (arg)
iv = ...
else
iv = SvIV_nomg(argsv);
if (!vectorize)
uv = f(iv) for some f.
goto integer;
case 'x' base = 16; goto uns_integer;
case 'u' base = 10; goto uns_integer;
...
uns_integer:
if (vectorize)
uv = ...
else if (arg)
uv = ...
else
uv = SvUV_nomg(argsv);
integer:
... do stuff with base and uv ...
Now it's more like
case 'd': base = -10; goto get_int_arg_val;
case 'i': base = -10; goto get_int_arg_val;
case 'x': base = 16; goto get_int_arg_val;
case 'u': base = 10; goto get_int_arg_val;
get_int_arg_val:
if (vectorize)
uv = ...
else if (base < 0) {
/* signed int type */
base = -base;
if (arg)
iv = ...
else
iv = SvIV_nomg(argsv);
uv = f(iv) for some f.
}
else {
/* unsigned int type */
if (arg)
uv = ...
else
uv = SvUV_nomg(argsv);
}
integer:
... do stuff with base and uv ...
Note that in particular the vectorize block of code is no longer
duplicated. This will also allow the next commit to handle Inf/overload
just after the 'get_int_arg_val' label rather than doing it before the
main switch and slowing down the non-integer format types.
Should be no functional changes