Skip to content

Commit

Permalink
Merge pull request #3581 from ethereum/reduce-len-call
Browse files Browse the repository at this point in the history
Optimization: reduce `len()` calls in `add_polynomialcoeff`
  • Loading branch information
hwwhww authored Jan 20, 2024
2 parents 3727a75 + 96e41bc commit f1dff5f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion specs/_features/eip7594/polynomial-commitments-sampling.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ def add_polynomialcoeff(a: PolynomialCoeff, b: PolynomialCoeff) -> PolynomialCoe
Sum the coefficient form polynomials ``a`` and ``b``.
"""
a, b = (a, b) if len(a) >= len(b) else (b, a)
return [(a[i] + (b[i] if i < len(b) else 0)) % BLS_MODULUS for i in range(len(a))]
length_a = len(a)
length_b = len(b)
return [(a[i] + (b[i] if i < length_b else 0)) % BLS_MODULUS for i in range(length_a)]
```

#### `neg_polynomialcoeff`
Expand Down

0 comments on commit f1dff5f

Please sign in to comment.