Optimized hot-loop for logits processor

This commit is contained in:
Niels Geens
2025-04-09 11:59:26 +02:00
parent 654c32c7ac
commit 8fb30c8ed0
17 changed files with 239 additions and 272 deletions

View File

@@ -5,22 +5,12 @@ use crate::*;
#[derive(Clone, Debug)]
pub struct TextContent {
element: Arc<schema::XsElement>,
buffer: String,
}
impl TextContent {
pub fn new(element: Arc<schema::XsElement>) -> Self {
Self {
element,
buffer: String::new(),
}
}
/// Create a new TextContent with the given initial buffer
pub fn with_buffer(element: Arc<schema::XsElement>, buffer: String) -> Self {
Self {
element,
buffer,
}
}
@@ -28,9 +18,8 @@ impl TextContent {
if c == '<' {
vec![Token::ElementCloseStart(ElementCloseStart::new(Arc::clone(&self.element)))]
} else {
vec![Token::TextContent(TextContent::with_buffer(
vec![Token::TextContent(TextContent::new(
Arc::clone(&self.element),
self.buffer + &c.to_string(),
))]
}
}