Skip to content

Commit

Permalink
refactor!: from compact_strains feat to raw_strains
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxOhn committed Nov 18, 2024
1 parent 60f4f89 commit ab5bede
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 20 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
run: >
cargo test
--doc
--no-default-features --features compact_strains
--no-default-features
default:
name: Default tests
Expand All @@ -48,7 +48,7 @@ jobs:
- name: Run all tests
run: >
cargo nextest run
--no-default-features --features compact_strains
--no-default-features
--no-fail-fast --failure-output=immediate-final
sync:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
--no-fail-fast --failure-output=immediate-final
non_compact:
name: Test without compact_strains feature
name: Test with raw_strains feature
runs-on: ubuntu-latest

steps:
Expand All @@ -97,5 +97,6 @@ jobs:
run: >
cargo nextest run
--no-default-features
--features raw_strains
--test '*'
--no-fail-fast --failure-output=immediate-final
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ description = "Difficulty and performance calculation for osu!"
keywords = ["osu", "pp", "stars", "performance", "difficulty"]

[features]
default = ["compact_strains"]
compact_strains = []
default = []
raw_strains = []
sync = []
tracing = ["rosu-map/tracing"]

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ Calculating performances: Median: 44.13µs | Mean: 45.53µs

### Features

| Flag | Description | Dependencies
| ----------------- | ------------------------------------- | ------------
| `default` | Enables the `compact_strains` feature |
| `compact_strains` | Storing internal strain values in a plain Vec introduces an out-of-memory risk on maliciously long maps (see [/b/3739922](https://osu.ppy.sh/b/3739922)). This feature stores strains more compactly, but comes with a ~5% loss in performance. |
| `sync` | Some gradual calculation types can only be shared across threads if this feature is enabled. This adds a performance penalty so only enable this if really needed. |
| `tracing` | Any error encountered during beatmap decoding will be logged through `tracing::error`. If this feature is **not** enabled, errors will be ignored. | [`tracing`]
| Flag | Description | Dependencies
| ------------- | ------------------- | ------------
| `default` | No features enabled |
| `raw_strains` | With this feature, internal strain values will be stored in a plain `Vec`. This introduces an out-of-memory risk on maliciously long maps (see [/b/3739922](https://osu.ppy.sh/b/3739922)), but comes with a ~5% gain in performance. |
| `sync` | Some gradual calculation types can only be shared across threads if this feature is enabled. This feature adds a small performance penalty. |
| `tracing` | Any error encountered during beatmap decoding will be logged through `tracing::error`. If this feature is **not** enabled, errors will be ignored. | [`tracing`]

### Bindings

Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,12 @@
//!
//! ## Features
//!
//! | Flag | Description | Dependencies
//! | ----------------- | ------------------------------------- | ------------
//! | `default` | Enables the `compact_strains` feature |
//! | `compact_strains` | Storing internal strain values in a plain Vec introduces an out-of-memory risk on maliciously long maps (see [/b/3739922](https://osu.ppy.sh/b/3739922)). This feature stores strains more compactly, but comes with a ~5% loss in performance. |
//! | `sync` | Some gradual calculation types can only be shared across threads if this feature is enabled. This adds a performance penalty so only enable this if really needed. |
//! | `tracing` | Any error encountered during beatmap decoding will be logged through `tracing::error`. If this feature is **not** enabled, errors will be ignored. | [`tracing`]
//! | Flag | Description | Dependencies
//! | ------------- | ------------------- | ------------
//! | `default` | No features enabled |
//! | `raw_strains` | With this feature, internal strain values will be stored in a plain `Vec`. This introduces an out-of-memory risk on maliciously long maps (see [/b/3739922](https://osu.ppy.sh/b/3739922)), but comes with a ~5% gain in performance. |
//! | `sync` | Some gradual calculation types can only be shared across threads if this feature is enabled. This feature adds a small performance penalty. |
//! | `tracing` | Any error encountered during beatmap decoding will be logged through `tracing::error`. If this feature is **not** enabled, errors will be ignored. | [`tracing`]
//!
//! ## Bindings
//!
Expand Down
6 changes: 3 additions & 3 deletions src/util/strains_vec.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use inner::*;

#[cfg(feature = "compact_strains")]
#[cfg(not(feature = "raw_strains"))]
mod inner {
use std::{iter::Copied, slice::Iter};

Expand Down Expand Up @@ -318,14 +318,14 @@ mod inner {
}
}

#[cfg(not(feature = "compact_strains"))]
#[cfg(feature = "raw_strains")]
mod inner {
use std::{
iter::Copied,
slice::{Iter, IterMut},
};

/// Plain wrapper around `Vec<f64>` because the `compact_strains` feature
/// Plain wrapper around `Vec<f64>` because the `raw_strains` feature
/// is disabled.
#[derive(Clone)]
pub struct StrainsVec {
Expand Down

0 comments on commit ab5bede

Please sign in to comment.