Skip to content

Commit

Permalink
Merge pull request #309 from qzhuyan/dev/william/perf-send-bin
Browse files Browse the repository at this point in the history
perf: prefer inspect binary to avoid copy
  • Loading branch information
qzhuyan authored Oct 18, 2024
2 parents b469ec2 + 28d22bc commit d22aa7b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions c_src/quicer_stream.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d22aa7b

Please sign in to comment.