From 0e51fa94450f6a5251f64bd0ad808f1fd1700802 Mon Sep 17 00:00:00 2001 From: Ibraheem Ahmed Date: Tue, 27 Feb 2024 15:48:45 -0500 Subject: [PATCH] simplify priority shifting --- src/tree.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/tree.rs b/src/tree.rs index 960599f..96e54aa 100644 --- a/src/tree.rs +++ b/src/tree.rs @@ -188,15 +188,9 @@ impl Node { updated -= 1; } - // build new index list + // update the index position if updated != i { - self.indices = [ - &self.indices[..updated], // unchanged prefix, might be empty - &self.indices[i..=i], // the index char we move - &self.indices[updated..i], // rest without char at 'pos' - &self.indices[i + 1..], - ] - .concat(); + self.indices[updated..=i].rotate_right(1); } updated