From 28d22bc3ec1a1c1ab069a9d5ae2c5845b97b0f67 Mon Sep 17 00:00:00 2001 From: William Yang Date: Thu, 17 Oct 2024 21:38:08 +0200 Subject: [PATCH] perf: prefer inspect binary to avoid copy --- c_src/quicer_stream.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/c_src/quicer_stream.c b/c_src/quicer_stream.c index 2b5c34f1..12dc048c 100644 --- a/c_src/quicer_stream.c +++ b/c_src/quicer_stream.c @@ -588,8 +588,8 @@ csend4(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) // // Allocates and builds the buffer to send over the stream. // - if (!(enif_inspect_iolist_as_binary(send_ctx->env, ebin, bin) - || enif_inspect_binary(send_ctx->env, ebin, bin)) + if (!(enif_inspect_binary(send_ctx->env, ebin, bin) + || enif_inspect_iolist_as_binary(send_ctx->env, ebin, bin)) || bin->size > UINT32_MAX) { @@ -692,8 +692,8 @@ send3(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[]) } ebin = enif_make_copy(send_ctx->env, ebin); - if (!(enif_inspect_iolist_as_binary(send_ctx->env, ebin, bin) - || enif_inspect_binary(send_ctx->env, ebin, bin)) + if (!(enif_inspect_binary(send_ctx->env, ebin, bin) + || enif_inspect_iolist_as_binary(send_ctx->env, ebin, bin)) || bin->size > UINT32_MAX) { res = ERROR_TUPLE_2(ATOM_BADARG);