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

View file

@ -58,12 +58,17 @@ my @errors = (
do { no warnings 'portable'; "\x{ffffffff}" }, qr/invalid codepoint encountered in string/,
);
plan tests => @tests + @errors/2 + 6;
plan tests => @tests*2 + @errors/2 + 6;
for my($in, $exp) (@tests) {
my $out = json_format $in;
is $out, $exp;
ok utf8::is_utf8($out);
$out = json_format $in, utf8 => 1;
utf8::encode(my $uexp = $exp);
is $out, $uexp;
ok !utf8::is_utf8($out);
}
for my ($in, $exp) (@errors) {