Skip to content

Conversation

@daywalker90
Copy link
Collaborator

Mirroring 60a0ed2

Changelog-None

  • The changelog has been updated in the relevant commit(s) according to the guidelines.
  • Tests have been added or modified to reflect the changes.
  • Documentation has been reviewed and updated as needed.
  • Related issues have been listed and linked, including any that this PR closes.

@daywalker90 daywalker90 requested a review from cdecker as a code owner November 20, 2025 10:35
@cdecker
Copy link
Member

cdecker commented Nov 24, 2025

ACK 9a6486e

self
}

pub fn hook_from_builder(mut self, hook: HookBuilder<S>) -> Builder<S, I, O> {
Copy link
Member

Choose a reason for hiding this comment

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

Is there a point in keeping the HookBuilder around? I quite like using mut HookBuilder as argument type, because it means we own the instance, and we can disect it however we like, so in this case I think we can skip the hook.name.clone() invokation and directly use hook.name, saving us a clone in normal operations 🤔

Very minor thing, but I was wondering what you think of such an optimization.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Afaik we don't keep it around since hook.build() consumes it. Since we need the String in name here and to make the Hook in build() we need to clone() it somewhere, right?

Copy link
Member

Choose a reason for hiding this comment

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

That's the thing that I'm wondering, if we consume the HookBuilder, the String is free to be reassigned, and the Builder could reuse the String. No idea if this is done by the compiler, and more of a curiosity to be honest, so this should absolutely not hold up progress. This can be merged as is.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think about every clone alot aswell 😄 . self.hooks has the hook.name as key and in the value struct. Both are owned so we must either

  • clone the name for the key or the value
  • use borrowed objects (then we probably need to start using lifetimes, which seems not worth it here imo)
  • refactor some stuff so we don't have the name in both key and value

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