Skip to content
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

sieve: Use saturating_add when computing next_base #61

Merged
merged 6 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ name: Continuous integration
on:
push:
branches:
- staging
- trying
- master
pull_request:

env:
CARGO_TERM_COLOR: always
Expand All @@ -21,10 +21,10 @@ jobs:
- rust: nightly
- rust: nightly-i686-unknown-linux-gnu
- rust: stable
target: mips64-unknown-linux-gnuabi64
target: s390x-unknown-linux-gnu

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
Expand All @@ -35,3 +35,18 @@ jobs:
env:
TARGET: ${{ matrix.target }}
run: ./ci/script.sh

# One job that "summarizes" the success state of this pipeline. This can then be added to branch
# protection, rather than having to add each job separately.
success:
name: bors
runs-on: ubuntu-latest
needs: [tests]
# Github branch protection is exceedingly silly and treats "jobs skipped because a dependency
# failed" as success. So we have to do some contortions to ensure the job fails if any of its
# dependencies fails.
if: always() # make sure this is never "skipped"
steps:
# Manually check the status of all dependencies. `if: failure()` does not work.
- name: check if any dependency failed
run: jq --exit-status 'all(.result == "success")' <<< '${{ toJson(needs) }}'
23 changes: 0 additions & 23 deletions .github/workflows/pr.yml

This file was deleted.

5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,8 @@ tag-name = "{{crate_name}}-{{version}}"
[package.metadata.release]
sign-tag = true
tag-name = "{{crate_name}}-{{version}}"

# Make sure all our slow_tests still check overflows in --release tests.
# (This doesn't affect downstream dependents building these libraries.)
[profile.release]
overflow-checks = true
8 changes: 0 additions & 8 deletions bors.toml

This file was deleted.

6 changes: 4 additions & 2 deletions primal-sieve/src/sieve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ impl Sieve {
let bits = &self.seen[base].bits;

let current_base = base_byte_count * wheel::BYTE_MODULO;
let next_base = current_base + bits.len() * wheel::BYTE_MODULO / 8;
let next_base = current_base.saturating_add(bits.len() * wheel::BYTE_MODULO / 8);

SievePrimes {
early,
Expand Down Expand Up @@ -404,7 +404,9 @@ impl<'a> SievePrimes<'a> {
match self.bits.next() {
Some(Item { bits, .. }) => {
self.base = self.next_base;
self.next_base += bits.len() * wheel::BYTE_MODULO / 8;
self.next_base = self
.next_base
.saturating_add(bits.len() * wheel::BYTE_MODULO / 8);
self.ones = bits.ones_from(0);
true
},
Expand Down