Skip to content

Commit 6425c3a

Browse files
committed
Code improvement
1 parent e5c2c6c commit 6425c3a

File tree

4 files changed

+3
-38
lines changed

4 files changed

+3
-38
lines changed

spartan_parallel/src/lib.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ fn write_bytes(mut f: &File, bytes: &[u8; 32]) -> std::io::Result<()> {
126126
for i in 0..size {
127127
write!(&mut f, "{} ", bytes[i])?;
128128
}
129-
writeln!(&mut f, "")?;
129+
writeln!(&mut f)?;
130130
Ok(())
131131
}
132132

@@ -285,7 +285,7 @@ impl<S: SpartanExtensionField> IOProofs<S> {
285285
input_indices = input_indices[..live_input.len()].to_vec();
286286

287287
// batch verify all proofs
288-
let _ = PolyEvalProof::verify_plain_batched_points(
288+
PolyEvalProof::verify_plain_batched_points(
289289
&self.proofs,
290290
transcript,
291291
[
@@ -313,9 +313,7 @@ impl<S: SpartanExtensionField> IOProofs<S> {
313313
live_input,
314314
]
315315
.concat(),
316-
)?;
317-
318-
Ok(())
316+
)
319317
}
320318
}
321319

spartan_parallel/src/scalar/fp.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -120,13 +120,11 @@ impl Zeroize for Scalar {
120120
impl Neg for Scalar {
121121
type Output = Scalar;
122122

123-
#[inline]
124123
fn neg(self) -> Scalar {
125124
self.0.neg().into()
126125
}
127126
}
128127
impl Default for Scalar {
129-
#[inline]
130128
fn default() -> Self {
131129
Self::zero()
132130
}
@@ -138,13 +136,11 @@ impl From<Goldilocks> for Scalar {
138136
}
139137
impl Scalar {
140138
/// Returns zero, the additive identity.
141-
#[inline]
142139
pub const fn zero() -> Self {
143140
Self(Goldilocks(0u64))
144141
}
145142

146143
/// Returns one, the multiplicative identity.
147-
#[inline]
148144
pub const fn one() -> Self {
149145
Self(Goldilocks(1u64))
150146
}
@@ -153,7 +149,6 @@ impl Scalar {
153149
impl<'a, 'b> Add<&'b Scalar> for &'a Scalar {
154150
type Output = Scalar;
155151

156-
#[inline]
157152
fn add(self, rhs: &'b Scalar) -> Scalar {
158153
self.inner().add(rhs.inner()).into()
159154
}
@@ -162,7 +157,6 @@ impl<'a, 'b> Add<&'b Scalar> for &'a Scalar {
162157
impl<'a, 'b> Sub<&'b Scalar> for &'a Scalar {
163158
type Output = Scalar;
164159

165-
#[inline]
166160
fn sub(self, rhs: &'b Scalar) -> Scalar {
167161
self.inner().sub(rhs.inner()).into()
168162
}
@@ -171,7 +165,6 @@ impl<'a, 'b> Sub<&'b Scalar> for &'a Scalar {
171165
impl<'a, 'b> Mul<&'b Scalar> for &'a Scalar {
172166
type Output = Scalar;
173167

174-
#[inline]
175168
fn mul(self, rhs: &'b Scalar) -> Scalar {
176169
self.inner().mul(rhs.inner()).into()
177170
}

spartan_parallel/src/scalar/fp2.rs

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,26 +117,22 @@ impl Zeroize for ScalarExt2 {
117117
impl Neg for ScalarExt2 {
118118
type Output = Self;
119119

120-
#[inline]
121120
fn neg(self) -> Self {
122121
self.0.neg().into()
123122
}
124123
}
125124
impl Default for ScalarExt2 {
126-
#[inline]
127125
fn default() -> Self {
128126
Self::zero()
129127
}
130128
}
131129
impl ScalarExt2 {
132130
/// Returns zero, the additive identity.
133-
#[inline]
134131
pub const fn zero() -> Self {
135132
Self(GoldilocksExt2::ZERO)
136133
}
137134

138135
/// Returns one, the multiplicative identity.
139-
#[inline]
140136
pub const fn one() -> Self {
141137
Self(GoldilocksExt2::ONE)
142138
}
@@ -145,7 +141,6 @@ impl ScalarExt2 {
145141
impl<'a, 'b> Add<&'b ScalarExt2> for &'a ScalarExt2 {
146142
type Output = ScalarExt2;
147143

148-
#[inline]
149144
fn add(self, rhs: &'b ScalarExt2) -> ScalarExt2 {
150145
self.inner().add(rhs.inner()).into()
151146
}
@@ -154,7 +149,6 @@ impl<'a, 'b> Add<&'b ScalarExt2> for &'a ScalarExt2 {
154149
impl<'a, 'b> Sub<&'b ScalarExt2> for &'a ScalarExt2 {
155150
type Output = ScalarExt2;
156151

157-
#[inline]
158152
fn sub(self, rhs: &'b ScalarExt2) -> ScalarExt2 {
159153
self.inner().sub(rhs.inner()).into()
160154
}
@@ -163,7 +157,6 @@ impl<'a, 'b> Sub<&'b ScalarExt2> for &'a ScalarExt2 {
163157
impl<'a, 'b> Mul<&'b ScalarExt2> for &'a ScalarExt2 {
164158
type Output = ScalarExt2;
165159

166-
#[inline]
167160
fn mul(self, rhs: &'b ScalarExt2) -> ScalarExt2 {
168161
let a = self.inner();
169162
let b = rhs.inner();

spartan_parallel/src/scalar/mod.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,21 @@ pub trait SpartanExtensionField:
8080
);
8181

8282
/// Return the neg of field element
83-
#[inline]
8483
fn negate(&self) -> Self {
8584
self.inner().neg().into()
8685
}
8786

8887
/// Doubles this field element.
89-
#[inline]
9088
fn double(&self) -> Self {
9189
self.add(*self)
9290
}
9391

9492
/// Squares this element.
95-
#[inline]
9693
fn square(&self) -> Self {
9794
self.mul(*self)
9895
}
9996

10097
/// Negates `self`.
101-
#[inline]
10298
fn neg(&self) -> Self {
10399
self.inner().neg().into()
104100
}
@@ -186,7 +182,6 @@ macro_rules! impl_add_binop_specify_output {
186182
impl<'b> Add<&'b $rhs> for $lhs {
187183
type Output = $output;
188184

189-
#[inline]
190185
fn add(self, rhs: &'b $rhs) -> $output {
191186
&self + rhs
192187
}
@@ -195,7 +190,6 @@ macro_rules! impl_add_binop_specify_output {
195190
impl<'a> Add<$rhs> for &'a $lhs {
196191
type Output = $output;
197192

198-
#[inline]
199193
fn add(self, rhs: $rhs) -> $output {
200194
self + &rhs
201195
}
@@ -204,7 +198,6 @@ macro_rules! impl_add_binop_specify_output {
204198
impl Add<$rhs> for $lhs {
205199
type Output = $output;
206200

207-
#[inline]
208201
fn add(self, rhs: $rhs) -> $output {
209202
&self + &rhs
210203
}
@@ -219,7 +212,6 @@ macro_rules! impl_sub_binop_specify_output {
219212
impl<'b> Sub<&'b $rhs> for $lhs {
220213
type Output = $output;
221214

222-
#[inline]
223215
fn sub(self, rhs: &'b $rhs) -> $output {
224216
&self - rhs
225217
}
@@ -228,7 +220,6 @@ macro_rules! impl_sub_binop_specify_output {
228220
impl<'a> Sub<$rhs> for &'a $lhs {
229221
type Output = $output;
230222

231-
#[inline]
232223
fn sub(self, rhs: $rhs) -> $output {
233224
self - &rhs
234225
}
@@ -237,7 +228,6 @@ macro_rules! impl_sub_binop_specify_output {
237228
impl Sub<$rhs> for $lhs {
238229
type Output = $output;
239230

240-
#[inline]
241231
fn sub(self, rhs: $rhs) -> $output {
242232
&self - &rhs
243233
}
@@ -261,7 +251,6 @@ macro_rules! impl_binops_multiplicative_mixed {
261251
impl<'b> Mul<&'b $rhs> for $lhs {
262252
type Output = $output;
263253

264-
#[inline]
265254
fn mul(self, rhs: &'b $rhs) -> $output {
266255
&self * rhs
267256
}
@@ -270,7 +259,6 @@ macro_rules! impl_binops_multiplicative_mixed {
270259
impl<'a> Mul<$rhs> for &'a $lhs {
271260
type Output = $output;
272261

273-
#[inline]
274262
fn mul(self, rhs: $rhs) -> $output {
275263
self * &rhs
276264
}
@@ -279,7 +267,6 @@ macro_rules! impl_binops_multiplicative_mixed {
279267
impl Mul<$rhs> for $lhs {
280268
type Output = $output;
281269

282-
#[inline]
283270
fn mul(self, rhs: $rhs) -> $output {
284271
&self * &rhs
285272
}
@@ -294,28 +281,24 @@ macro_rules! impl_binops_additive {
294281
crate::impl_binops_additive_specify_output!($lhs, $rhs, $lhs);
295282

296283
impl SubAssign<$rhs> for $lhs {
297-
#[inline]
298284
fn sub_assign(&mut self, rhs: $rhs) {
299285
*self = &*self - &rhs;
300286
}
301287
}
302288

303289
impl AddAssign<$rhs> for $lhs {
304-
#[inline]
305290
fn add_assign(&mut self, rhs: $rhs) {
306291
*self = &*self + &rhs;
307292
}
308293
}
309294

310295
impl<'b> SubAssign<&'b $rhs> for $lhs {
311-
#[inline]
312296
fn sub_assign(&mut self, rhs: &'b $rhs) {
313297
*self = &*self - rhs;
314298
}
315299
}
316300

317301
impl<'b> AddAssign<&'b $rhs> for $lhs {
318-
#[inline]
319302
fn add_assign(&mut self, rhs: &'b $rhs) {
320303
*self = &*self + rhs;
321304
}
@@ -330,14 +313,12 @@ macro_rules! impl_binops_multiplicative {
330313
crate::impl_binops_multiplicative_mixed!($lhs, $rhs, $lhs);
331314

332315
impl MulAssign<$rhs> for $lhs {
333-
#[inline]
334316
fn mul_assign(&mut self, rhs: $rhs) {
335317
*self = &*self * &rhs;
336318
}
337319
}
338320

339321
impl<'b> MulAssign<&'b $rhs> for $lhs {
340-
#[inline]
341322
fn mul_assign(&mut self, rhs: &'b $rhs) {
342323
*self = &*self * rhs;
343324
}

0 commit comments

Comments
 (0)