Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

instruducing inner data for Client to avoid extra Allocations #641

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

MrAliSalehi
Copy link

Pull Request

Related issue

What does this PR do?

Hello there, Thank your for your Library <3

this PR adds an extra object into the Client type, it wraps the inner content inside an Arc in order to avoid allocations when using Clone . this is a simple and known pattern in Rust community.
tho this can be done from outer scope where users could just simply wrap the Client itself inside an Arc, its a nice feature to have inside in case users forget about this case and accidentally Clone the Client without an Arc.

this PR also includes an impl (perhaps it should be placed somewhere else, im not sure about the author's preference on this) to deref the Client into ClientInner. this allows us to user the self. (the client ) normally just like before without needing to call self.inner.

also i added 2 .clone() to the test to make them work normally. which i think is not really important.

this PR should not introduce any breaking changes for users (neither for developers & contributors).

PR checklist

Please check if your PR fulfills the following requirements:

  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Copy link
Member

@curquiza curquiza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @MrAliSalehi

Thank you for your PR
Can you fix the rust format Ci please?

Capture d’écran 2025-02-10 à 16 59 00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants