refactor!: from compact_strains feat to raw_strains

This commit is contained in:
MaxOhn
2024-11-18 16:38:53 +01:00
parent 60f4f89cdb
commit ab5beded06
5 changed files with 21 additions and 20 deletions
+4 -3
View File
@@ -26,7 +26,7 @@ jobs:
run: > run: >
cargo test cargo test
--doc --doc
--no-default-features --features compact_strains --no-default-features
default: default:
name: Default tests name: Default tests
@@ -48,7 +48,7 @@ jobs:
- name: Run all tests - name: Run all tests
run: > run: >
cargo nextest run cargo nextest run
--no-default-features --features compact_strains --no-default-features
--no-fail-fast --failure-output=immediate-final --no-fail-fast --failure-output=immediate-final
sync: sync:
@@ -77,7 +77,7 @@ jobs:
--no-fail-fast --failure-output=immediate-final --no-fail-fast --failure-output=immediate-final
non_compact: non_compact:
name: Test without compact_strains feature name: Test with raw_strains feature
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
@@ -97,5 +97,6 @@ jobs:
run: > run: >
cargo nextest run cargo nextest run
--no-default-features --no-default-features
--features raw_strains
--test '*' --test '*'
--no-fail-fast --failure-output=immediate-final --no-fail-fast --failure-output=immediate-final
+2 -2
View File
@@ -11,8 +11,8 @@ description = "Difficulty and performance calculation for osu!"
keywords = ["osu", "pp", "stars", "performance", "difficulty"] keywords = ["osu", "pp", "stars", "performance", "difficulty"]
[features] [features]
default = ["compact_strains"] default = []
compact_strains = [] raw_strains = []
sync = [] sync = []
tracing = ["rosu-map/tracing"] tracing = ["rosu-map/tracing"]
+4 -4
View File
@@ -122,10 +122,10 @@ Calculating performances: Median: 44.13µs | Mean: 45.53µs
### Features ### Features
| Flag | Description | Dependencies | Flag | Description | Dependencies
| ----------------- | ------------------------------------- | ------------ | ------------- | ------------------- | ------------
| `default` | Enables the `compact_strains` feature | | `default` | No features enabled |
| `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. | | `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 adds a performance penalty so only enable this if really needed. | | `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`] | `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 ### Bindings
+4 -4
View File
@@ -118,10 +118,10 @@
//! ## Features //! ## Features
//! //!
//! | Flag | Description | Dependencies //! | Flag | Description | Dependencies
//! | ----------------- | ------------------------------------- | ------------ //! | ------------- | ------------------- | ------------
//! | `default` | Enables the `compact_strains` feature | //! | `default` | No features enabled |
//! | `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. | //! | `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 adds a performance penalty so only enable this if really needed. | //! | `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`] //! | `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 //! ## Bindings
+3 -3
View File
@@ -1,6 +1,6 @@
pub use inner::*; pub use inner::*;
#[cfg(feature = "compact_strains")] #[cfg(not(feature = "raw_strains"))]
mod inner { mod inner {
use std::{iter::Copied, slice::Iter}; use std::{iter::Copied, slice::Iter};
@@ -318,14 +318,14 @@ mod inner {
} }
} }
#[cfg(not(feature = "compact_strains"))] #[cfg(feature = "raw_strains")]
mod inner { mod inner {
use std::{ use std::{
iter::Copied, iter::Copied,
slice::{Iter, IterMut}, 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. /// is disabled.
#[derive(Clone)] #[derive(Clone)]
pub struct StrainsVec { pub struct StrainsVec {