perf: eliminate unnecessary heap allocations across agent loop, memory, and channels

- Replace clone()+clear() with std::mem::take() in chunker (items 1, 6)
- Add Vec::with_capacity() hints in chunker split functions (item 2)
- Replace collect::<Vec<_>>().join() with direct iteration in IRC and
  email channels (item 3)
- Share heading strings via Rc<str> instead of cloning per chunk (item 5)
- Use borrowed references in provider tool spec types to avoid cloning
  name/description/parameters per tool per request (item 7)

Closes #712

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Alex Gorevski 2026-02-18 19:02:10 -08:00
parent dce7280812
commit a4b27d2afe
6 changed files with 77 additions and 63 deletions

View file

@ -154,7 +154,14 @@ impl EmailChannel {
_ => {}
}
}
result.split_whitespace().collect::<Vec<_>>().join(" ")
let mut normalized = String::with_capacity(result.len());
for word in result.split_whitespace() {
if !normalized.is_empty() {
normalized.push(' ');
}
normalized.push_str(word);
}
normalized
}
/// Extract the sender address from a parsed email