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:
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user