Skip to content

perf: optimize SepticExtension field arithmetic operations #2410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

Lil-Duckling-22
Copy link

Motivation

The previous implementation of polynomial multiplication in SepticExtension performed unnecessary clone operations and computed results involving zero coefficients. This introduced avoidable overhead, especially in arithmetic-heavy workloads.

Solution

Optimized the Mul implementations for both owned and borrowed Polynomial:

  • Skips multiplication by zero coefficients, significantly improving performance in sparse polynomials.
  • Uses unsafe indexing (get_unchecked_mut) in the inner loop to reduce bounds checks in a performance-critical path. This is safe because index bounds are guaranteed by construction.
  • Reduced redundant allocations and cloning of coefficient values.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@leruaa
Copy link
Contributor

leruaa commented Aug 4, 2025

As mentioned in the pull request template, trivial PRs are generally not accepted to not encourage PR farming.

@leruaa leruaa closed this Aug 4, 2025
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