From d0b4c76262338624782cca4d6f664df1a335456e Mon Sep 17 00:00:00 2001 From: Jakob Stoklund Olesen Date: Fri, 6 Oct 2017 09:20:39 -0700 Subject: [PATCH] Use a non-allocating sort algorithm. The sort_unstable* functions are available in stable Rust now. These functions never allocate memory. --- lib/cretonne/src/regalloc/spilling.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/cretonne/src/regalloc/spilling.rs b/lib/cretonne/src/regalloc/spilling.rs index 4fe14a9528..a4fb4ededd 100644 --- a/lib/cretonne/src/regalloc/spilling.rs +++ b/lib/cretonne/src/regalloc/spilling.rs @@ -356,9 +356,8 @@ impl<'a> Context<'a> { // Leave `self.reg_uses` empty. fn process_reg_uses(&mut self, inst: Inst, tracker: &LiveValueTracker) { // We're looking for multiple uses of the same value, so start by sorting by value. The - // secondary `opidx` key makes it possible to use an unstable sort once that is available - // outside nightly Rust. - self.reg_uses.sort_by_key(|u| (u.value, u.opidx)); + // secondary `opidx` key makes it possible to use an unstable (non-allocating) sort. + self.reg_uses.sort_unstable_by_key(|u| (u.value, u.opidx)); for i in 0..self.reg_uses.len() { let ru = self.reg_uses[i];