Elk memory: avoid cloning all operations in `toposort`
mortendahl opened this issue · comments
Morten Dahl commented
toposort
is currently cloning operations as part of constructing its output:
pub fn toposort(&self) -> Result<NamedComputation> {
let graph = self.as_graph();
let toposort = toposort(&graph, None).map_err(|_| {
Error::MalformedComputation("There is a cycle detected in the runtime graph".into())
})?;
let operations = toposort
.iter()
.map(|node| self.operations[graph[*node].1].clone())
.collect();
...
Maybe there's a way this can be avoided by eg consuming comp
instead.
Morten Dahl commented
It would be nice to rearrange self.operations
according to toposort
, but couldn't find straight-forward way of doing this.