allocate curve length vec with capacity
This commit is contained in:
+2
-1
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user