MCPcopy Create free account
hub / github.com/ChrisFeldmeier/OpenCodeRust / estimate

Function estimate

crates/opencode-util/src/util.rs:87–92  ·  view source on GitHub ↗
(input: &str)

Source from the content-addressed store, hash-verified

85 const CHARS_PER_TOKEN: usize = 4;
86
87 pub fn estimate(input: &str) -> usize {
88 if input.is_empty() {
89 return 0;
90 }
91 input.len() / CHARS_PER_TOKEN
92 }
93
94 pub fn estimate_messages(messages: &[&str]) -> usize {
95 messages.iter().map(|m| estimate(m)).sum()

Callers 1

estimate_messagesFunction · 0.85

Calls 1

is_emptyMethod · 0.80

Tested by

no test coverage detected