use proper default capacities
This commit is contained in:
@@ -23,11 +23,22 @@ pub trait ISkill {
|
||||
type DifficultyObjects<'a>: ?Sized;
|
||||
}
|
||||
|
||||
#[derive(Clone, Default)]
|
||||
#[derive(Clone)]
|
||||
pub struct StrainSkill {
|
||||
pub curr_section_peak: f64,
|
||||
pub curr_section_end: f64,
|
||||
pub strain_peaks: Vec<f64>, // TODO: default capacity
|
||||
pub strain_peaks: Vec<f64>,
|
||||
}
|
||||
|
||||
impl Default for StrainSkill {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
curr_section_peak: 0.0,
|
||||
curr_section_end: 0.0,
|
||||
// mean=386.81 | median=279
|
||||
strain_peaks: Vec::with_capacity(256),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl StrainSkill {
|
||||
|
||||
@@ -46,13 +46,15 @@ pub fn convert_objects(
|
||||
hr: bool,
|
||||
cs: f32,
|
||||
) -> Vec<PalpableObject> {
|
||||
// TODO: check for better default capacity
|
||||
let mut palpable_objects = Vec::with_capacity(converted.map.hit_objects.len() * 2);
|
||||
// mean=686.54 | median=501
|
||||
let mut palpable_objects = Vec::with_capacity(512);
|
||||
|
||||
let mut bufs = JuiceStreamBufs {
|
||||
curve: CurveBuffers::default(),
|
||||
nested_objects: Vec::new(), // TODO: default capacity
|
||||
ticks: Vec::new(), // TODO: default capacity
|
||||
// mean=31.65 | median=16
|
||||
nested_objects: Vec::with_capacity(16),
|
||||
// mean=5.21 | median=4
|
||||
ticks: Vec::new(),
|
||||
};
|
||||
|
||||
let mut rng = Random::new(RNG_SEED);
|
||||
|
||||
@@ -77,9 +77,8 @@ fn convert(map: &mut Beatmap) {
|
||||
let mut last_values = PrevValues::default();
|
||||
let mut curve_bufs = CurveBuffers::default();
|
||||
|
||||
// TODO: find proper default
|
||||
let capacity = map.hit_objects.len() * 2;
|
||||
let mut new_hit_objects = Vec::with_capacity(capacity);
|
||||
// mean=668.7 | median=512
|
||||
let mut new_hit_objects = Vec::with_capacity(512);
|
||||
|
||||
for (obj, sound) in map.hit_objects.iter().zip(map.hit_sounds.iter().copied()) {
|
||||
match obj.kind {
|
||||
|
||||
@@ -259,9 +259,12 @@ impl DecodeState for BeatmapState {
|
||||
pending_timing_point: None,
|
||||
pending_difficulty_point: None,
|
||||
pending_effect_point: None,
|
||||
curve_points: Vec::new(), // TODO: check for default size
|
||||
vertices: Vec::new(), // TODO: check for default size
|
||||
point_split: Vec::new(), // TODO: check for default size
|
||||
// mean=13.11 | median=8
|
||||
curve_points: Vec::with_capacity(8),
|
||||
// mean=16.27 | median=8
|
||||
vertices: Vec::with_capacity(8),
|
||||
// mean=19.97 | median=8
|
||||
point_split: Vec::with_capacity(8),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-1
@@ -34,7 +34,8 @@ pub fn convert_objects(
|
||||
attrs: &mut OsuDifficultyAttributes,
|
||||
) -> Vec<OsuObject> {
|
||||
let mut curve_bufs = CurveBuffers::default();
|
||||
let mut ticks_buf = Vec::new(); // TODO: default capacity
|
||||
// mean=5.16 | median=4
|
||||
let mut ticks_buf = Vec::new();
|
||||
|
||||
let mut osu_objects: Vec<_> = converted
|
||||
.map
|
||||
|
||||
@@ -29,7 +29,8 @@ impl Speed {
|
||||
Self {
|
||||
curr_strain: 0.0,
|
||||
curr_rhythm: 0.0,
|
||||
object_strains: Vec::new(), // TODO: default capacity
|
||||
// mean=406.72 | median=307
|
||||
object_strains: Vec::with_capacity(256),
|
||||
hit_window,
|
||||
inner: OsuStrainSkill::default(),
|
||||
}
|
||||
|
||||
@@ -92,9 +92,12 @@ impl TaikoDifficultyObjects {
|
||||
pub fn with_capacity(capacity: usize) -> Self {
|
||||
Self {
|
||||
objects: Vec::with_capacity(capacity),
|
||||
center_hit_objects: Vec::default(), // TODO: default capacity
|
||||
rim_hit_objects: Vec::default(), // TODO: default capacity
|
||||
note_objects: Vec::default(), // TODO: default capacity
|
||||
// mean=301.7 | median=215
|
||||
center_hit_objects: Vec::with_capacity(256),
|
||||
// mean=309.21 | median=229
|
||||
rim_hit_objects: Vec::with_capacity(256),
|
||||
// mean=610.91 | median=466
|
||||
note_objects: Vec::with_capacity(256),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -46,12 +46,16 @@ impl Peaks {
|
||||
}
|
||||
|
||||
pub fn difficulty_value(self) -> f64 {
|
||||
let mut peaks = Vec::new(); // TODO: default capacity
|
||||
|
||||
let color_peaks = self.color.get_curr_strain_peaks();
|
||||
let rhythm_peaks = self.rhythm.get_curr_strain_peaks();
|
||||
let stamina_peaks = self.stamina.get_curr_strain_peaks();
|
||||
|
||||
let cap = color_peaks
|
||||
.len()
|
||||
.min(rhythm_peaks.len())
|
||||
.min(stamina_peaks.len());
|
||||
let mut peaks = Vec::with_capacity(cap);
|
||||
|
||||
let zip = color_peaks
|
||||
.iter()
|
||||
.copied()
|
||||
|
||||
Reference in New Issue
Block a user