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

Make ConnectionEnd::versions method non-allocating #55

Closed
5 tasks
seanchen1991 opened this issue Feb 15, 2022 · 0 comments
Closed
5 tasks

Make ConnectionEnd::versions method non-allocating #55

seanchen1991 opened this issue Feb 15, 2022 · 0 comments
Assignees

Comments

@seanchen1991
Copy link
Contributor

Crate

ibc-relayer

Summary

The ConnectionEnd::versions getter method clones the versions vector. I think it would make more sense to have this method not allocate and return a &’a [Versions] instead.

Problem Definition

Getter methods in Rust typically return a reference. It’s not explicit in the ConnectionEnd::versions method that it is allocating, so these calls are more expensive than they might seem.

Proposal

It looks like it would be pretty straightforward to change the method to return a slice, as well as convert any downstream calls to the method to accept a &'a [Version] instead. Some call sites will require a .to_vec to get back an owned vector, but I think it makes more sense to do that than to have the versions getter method return an owned vector.

Acceptance Criteria

ConnectionEnd::versions returns a &’a [Versions] and any code calling this method is revised to accept this type as input.


For Admin Use

  • Not duplicate issue
  • Appropriate labels applied
  • Appropriate milestone (priority) applied
  • Appropriate contributors tagged
  • Contributor assigned/self-assigned
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

No branches or pull requests

1 participant