FU::Util: Add gzip_compress() wrapper for libdeflate/zlib-ng/zlib

And use it for automatic output compression in FU, as (potentially)
faster alternative to Compress::Raw::Zlib.

Was also planning to maybe add support for Zstd or Brotli, but given the
performance of libdeflate, I'm not sure that's really necessary. Brotli
does tend to do a better job at compressing HTML, though.
This commit is contained in:
Yorhel 2025-03-18 16:58:31 +01:00
parent c2e0f158ac
commit bc33fe53f0
5 changed files with 237 additions and 10 deletions

15
FU.xs
View file

@ -27,10 +27,12 @@
#include "c/khashl.h"
#include "c/common.c"
#include "c/compress.c"
#include "c/fcgi.c"
#include "c/fdpass.c"
#include "c/jsonfmt.c"
#include "c/jsonparse.c"
#include "c/fdpass.c"
#include "c/fcgi.c"
#include "c/xmlwr.c"
#include "c/libpq.h"
@ -115,6 +117,15 @@ void json_parse(SV *val, ...)
CODE:
ST(0) = fujson_parse_xs(aTHX_ ax, items, val);
void gzip_lib()
PROTOTYPE:
CODE:
ST(0) = sv_2mortal(newSVpv(fugz_lib(), 0));
void gzip_compress(IV level, SV *in)
CODE:
ST(0) = fugz_compress(aTHX_ level, in);
void fdpass_send(int socket, int fd, SV *data)
CODE:
STRLEN buflen;