Skip to content

Reduce allocations for PgBindIter #4085

@notABot101010

Description

@notABot101010

I have found these related issues/pull requests

#3651

Description

Hello,
The new PgBindIter is awesome, but it seems that it allocates too much memory.

I would like to submit a PR to .reserve() the PgArgumentBuffer using iter.size_hint() in encode_inner https://github.com/launchbadge/sqlx/blob/e8384f2a00173c2b120eea72e99d120557fced8b/sqlx-postgres/src/bind_iter.rs#L83

in order to reduce the number of allocations performed by PgArgumentBuffer.

Prefered solution

.reserve() the PgArgumentBuffer using iter.size_hint() in encode_inner

Is this a breaking change? Why or why not?

no, just a small improvement, 1-line change

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions