allocate curve length vec with capacity

This commit is contained in:
MaxOhn
2021-11-13 17:28:26 +01:00
parent d39d9ae426
commit 1a7127be7f
2 changed files with 4 additions and 5 deletions
+2 -1
View File
@@ -158,7 +158,8 @@ impl Curve {
expected_len: f64,
) -> Vec<f64> {
let mut calculated_len = 0.0;
let mut cumulative_len = vec![0.0];
let mut cumulative_len = Vec::with_capacity(path.len());
cumulative_len.push(0.0);
for (&curr, &next) in path.iter().zip(path.iter().skip(1)) {
let diff = next - curr;
+2 -4
View File
@@ -174,10 +174,8 @@ impl<'h> DifficultyObject<'h> {
// * this finds the positional delta from the required
// * radius and the current position, and updates the
// * currCursorPosition accordingly, as well as rewarding distance.
curr_cursor_pos = curr_cursor_pos
+ curr_movement
* ((curr_movement_len - required_movement) / curr_movement_len)
as f32;
curr_cursor_pos += curr_movement
* ((curr_movement_len - required_movement) / curr_movement_len) as f32;
curr_movement_len *=
(curr_movement_len - required_movement) / curr_movement_len;