meilisearch / meilisearch-rust

Rust wrapper for the Meilisearch API.

Home Page:https://www.meilisearch.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Performances: Stop initializing large vector that we’re not going to read

irevoire opened this issue · comments

commented

When streaming a payload with meilisearch-rust, we have to convert a structure implementing AsyncRead to a structure implementing Stream.
This means I have to call poll_read, which have a &[u8] in parameter.

Currently, to avoid doing anything wrong, I initialize every byte of my buffer to zero here:

this.buf.resize(*this.capacity, 0);

But ideally, this shouldn’t be necessary since we’re never reading these bytes before writing to it.