summaryrefslogtreecommitdiff
path: root/chain/src/default.rs
diff options
context:
space:
mode:
Diffstat (limited to 'chain/src/default.rs')
-rw-r--r--chain/src/default.rs23
1 files changed, 7 insertions, 16 deletions
diff --git a/chain/src/default.rs b/chain/src/default.rs
index b9d7fe6..22befff 100644
--- a/chain/src/default.rs
+++ b/chain/src/default.rs
@@ -10,10 +10,7 @@ use crate::atom::{Atom, DefaultAtom};
use core::fmt::Display;
use forest::{default::DefaultForest, Forest};
use grammar::{Error as GrammarError, GrammarLabel, GrammarLabelType, TNT};
-#[allow(unused_imports)]
-use graph::{
- labelled::DLGBuilder, Builder, DLGraph, Graph, LabelExtGraph, LabelGraph, ParentsGraph,
-};
+use graph::{labelled::DLGBuilder, Builder, DLGraph, Graph, LabelExtGraph, LabelGraph};
use std::collections::{HashMap as Map, TryReserveError};
@@ -156,11 +153,13 @@ impl Iterator for DerIter {
None
}
} else {
- self.index = DerIterIndex::Single(0);
+ // If the zero-th element is present, we will
+ // advance the index to one; if it is not present,
+ // we will stop iteration. In each case we can
+ // safely set the index to one.
+ self.index = DerIterIndex::Single(1);
if let Some((edge, to)) = self.singles.first() {
- self.index = DerIterIndex::Single(1);
-
Some(TwoLayers::One(*edge, *to))
} else {
None
@@ -776,15 +775,7 @@ mod test_chain {
println!("repeating {repeat_times} times");
- let input = {
- let mut result = Vec::with_capacity(input_template.len() * repeat_times);
-
- for _ in 0..repeat_times {
- result.extend(input_template.iter().copied());
- }
-
- result
- };
+ let input = input_template.repeat(repeat_times);
let start = std::time::Instant::now();