Skip to content

Commit 54851fe

Browse files
committed
Remove extra lookups and memory allocations from tsort graph construction
1 parent f70e3d4 commit 54851fe

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/uu/tsort/src/tsort.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ enum TsortError {
4242

4343
impl UError for TsortError {}
4444

45-
46-
4745
#[uucore::main]
4846
pub fn uumain(args: impl uucore::Args) -> UResult<()> {
4947
let matches = uucore::clap_localization::handle_clap_result(uu_app(), args)?;
@@ -65,14 +63,14 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
6563

6664
// Create the directed graph from pairs of tokens in the input data.
6765
let mut g = Graph::new(input.to_string_lossy().to_string());
68-
69-
let mut edgetokens = data.split_whitespace();
70-
66+
67+
let mut edge_tokens = data.split_whitespace();
68+
7169
loop {
72-
let Some(a) = edgetokens.next() else {
70+
let Some(a) = edge_tokens.next() else {
7371
break;
7472
};
75-
let Some(b) = edgetokens.next() else {
73+
let Some(b) = edge_tokens.next() else {
7674
return Err(TsortError::NumTokensOdd(input.to_string_lossy().to_string()).into());
7775
};
7876
g.add_edge(a, b);

0 commit comments

Comments
 (0)