From 2bcf91b3f3299d106a1288080ee2063cf847ca7b Mon Sep 17 00:00:00 2001 From: "Tom D." Date: Mon, 24 Jun 2024 20:39:14 +0200 Subject: [PATCH] attempt to do away with BTreeMap --- src/uu/tsort/src/tsort.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/uu/tsort/src/tsort.rs b/src/uu/tsort/src/tsort.rs index 969577a3e66..595458812c7 100644 --- a/src/uu/tsort/src/tsort.rs +++ b/src/uu/tsort/src/tsort.rs @@ -3,7 +3,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. use clap::{crate_version, Arg, Command}; -use std::collections::{BTreeMap, HashSet, VecDeque}; +use std::collections::{HashMap, HashSet, VecDeque}; use std::fmt::Write; use std::fs::File; use std::io::{stdin, BufReader, Read}; @@ -132,14 +132,14 @@ impl<'input> Node<'input> { } struct Graph<'input> { - nodes: BTreeMap<&'input str, Node<'input>>, + nodes: HashMap<&'input str, Node<'input>>, result: Result, Vec<&'input str>>, } impl<'input> Graph<'input> { fn new() -> Self { Self { - nodes: BTreeMap::new(), + nodes: HashMap::new(), result: Ok(Vec::new()), } } @@ -176,7 +176,7 @@ impl<'input> Graph<'input> { } }) .collect(); - + independent_nodes_queue.make_contiguous().sort_unstable(); while let Some(name_of_next_node_to_process) = independent_nodes_queue.pop_front() { result.push(name_of_next_node_to_process); if let Some(node_to_process) = self.nodes.remove(name_of_next_node_to_process) {