starknet-rs icon indicating copy to clipboard operation
starknet-rs copied to clipboard

Improve `FieldElement` struct construction

Open tcoratger opened this issue 1 year ago • 3 comments

Description

This pull request refactors the FieldElement structure to remove the unnecessary inner field, enhancing efficiency and minimizing struct size. Additionally, it implements the std::ops::Deref and std::ops::DerefMut traits to facilitate standard struct manipulations.

Changes

  • Removed the inner field from the FieldElement structure.
  • Implemented std::ops::Deref and std::ops::DerefMut traits for improved struct operations.

Impact

  • Improved efficiency by eliminating redundant struct fields.
  • Reduced struct size for better memory optimization.
  • Simplified struct manipulation with the addition of trait implementations.

tcoratger avatar Feb 17 '24 17:02 tcoratger

TBH I don't think the inner part makes any difference. I could be wrong but I think a single field struct should be exactly equivalent to a newtype struct in terms of performance. So changing that for better performance doesn't feel justified.

xJonathanLEI avatar Mar 27 '24 17:03 xJonathanLEI

TBH I don't think the inner part makes any difference. I could be wrong but I think a single field struct should be exactly equivalent to a newtype struct in terms of performance. So changing that for better performance doesn't feel justified.

This one doesn't seem really relevant since we have this one in the pipeline: https://github.com/xJonathanLEI/starknet-rs/pull/562 which will delete all of this.

tcoratger avatar Mar 27 '24 17:03 tcoratger

Yeah that's true.

xJonathanLEI avatar Mar 27 '24 17:03 xJonathanLEI

starknet-ff was removed as part of #562. Closing this now as it's no longer relevant.

xJonathanLEI avatar Jun 17 '24 04:06 xJonathanLEI