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
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
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
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
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
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
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
Collaborator

Choose a reason for hiding this comment

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

Ditto

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