jsonfmt: Move arg parsing into XS

Going to need a way to pass arguments into the XS function anyway, so
might as well do the entire arg parsing step in XS while we're at it.
Provides a significant speedup for tiny inputs as well, but I don't find
that too interesting.
This commit is contained in:
Yorhel 2025-01-29 11:42:13 +01:00
parent e0161cd22c
commit 8ef2a724d1
6 changed files with 40 additions and 18 deletions

8
FU.xs
View file

@ -10,10 +10,6 @@ MODULE = FU PACKAGE = FU::XS
PROTOTYPES: DISABLE
void json_format(SV *val)
void json_format(SV *val, ...)
CODE:
fustr buf;
fustr_init(&buf, 128);
fujson_fmt(aTHX_ &buf, val);
ST(0) = fustr_done(&buf);
SvUTF8_on(ST(0));
ST(0) = fujson_fmt_xs(aTHX_ ax, items, val);