Skip to content

Inline always in _monty fields#15

Open
ElijahVlasov wants to merge 1 commit intomainfrom
ElijahVlasov/inline-ops
Open

Inline always in _monty fields#15
ElijahVlasov wants to merge 1 commit intomainfrom
ElijahVlasov/inline-ops

Conversation

@ElijahVlasov
Copy link
Copy Markdown
Collaborator

The methods of monty fields are mostly delegates so let's inline(always) probably?

fn from_with_cfg(value: $t, cfg: &Self::Config) -> Self {
let abs: BoxedUint = value.into();
let abs = abs.resize(cfg.modulus().bits_precision());
Self(BoxedMontyForm::new(abs, cfg.clone()))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Not sure we actually want this inlined, it's rather long

fn from_with_cfg(value: &crypto_bigint::Uint<LIMBS>, cfg: &Self::Config) -> Self {
let value: BoxedUint = value.into();
let value = value.resize(cfg.modulus().bits_precision());
Self(BoxedMontyForm::new(value, cfg.clone()))
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ditto

#[inline(always)]
fn modulus_minus_one_div_two(&self) -> Self::Inner {
let value = self.0.params().modulus().clone().get();
(value - BoxedUint::one()) / NonZero::new(BoxedUint::from(2_u8)).unwrap()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ditto

impl<const LIMBS: usize, const LIMBS2: usize> FromWithConfig<&Int<LIMBS2>> for MontyField<LIMBS> {
#[allow(clippy::arithmetic_side_effects)] // False alert
#[inline(always)]
fn from_with_cfg(value: &Int<LIMBS2>, cfg: &Self::Config) -> Self {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ditto

impl<const LIMBS: usize, const LIMBS2: usize> FromWithConfig<&Uint<LIMBS2>> for MontyField<LIMBS> {
#[allow(clippy::arithmetic_side_effects)] // False alert
#[inline(always)]
fn from_with_cfg(value: &Uint<LIMBS2>, cfg: &Self::Config) -> Self {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ditto

#[allow(clippy::arithmetic_side_effects)] // False alert
#[inline(always)]
fn modulus_minus_one_div_two(&self) -> Self::Inner {
let value = self.0.params().modulus().get();
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Ditto

@maksimryndin
Copy link
Copy Markdown

@codex review

@chatgpt-codex-connector
Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

3 participants