Reduce segment cloning when rendering messages (#33340)
While working on retries, I discovered some opportunities to reduce cloning of message segments. These segments have full `String`s (not `SharedString`s), so cloning them means copying cloning all the bytes of all the strings in the message, which would be nice to avoid! Release Notes: - N/A
This commit is contained in:
parent
8e831ced5b
commit
4516b099e7
2 changed files with 98 additions and 86 deletions
|
@ -198,6 +198,13 @@ impl MessageSegment {
|
|||
Self::RedactedThinking(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn text(&self) -> Option<&str> {
|
||||
match self {
|
||||
MessageSegment::Text(text) => Some(text),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue