diff --git a/src/fst/engine.rs b/src/fst/engine.rs index e5bb028..212fdbf 100644 --- a/src/fst/engine.rs +++ b/src/fst/engine.rs @@ -122,8 +122,10 @@ fn shortest_output(fst: &VectorFst) -> Option { /// shortest path's output. Returns `None` if the input is not in the domain /// (empty composition) or the shortest path emits nothing. pub fn apply(fst: &VectorFst, input: &str) -> Option { + // Borrow the grammar: cloning it per call copied the whole FST (several MB + // for es verbalize) once per token. let mut composed: VectorFst = - compose(byte_acceptor(input), fst.clone()).ok()?; + compose::<_, VectorFst<_>, VectorFst<_>, _, _, _>(byte_acceptor(input), fst).ok()?; if composed.num_states() == 0 || composed.start().is_none() { return None; }