MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / split_content_lines

Function split_content_lines

atomic-core/src/record/workflow/record/mod.rs:1187–1203  ·  view source on GitHub ↗

Split content into lines, preserving line endings. Returns slices into the original content.

(content: &[u8])

Source from the content-addressed store, hash-verified

1185/// Split content into lines, preserving line endings.
1186/// Returns slices into the original content.
1187fn split_content_lines(content: &[u8]) -> Vec<&[u8]> {
1188 if content.is_empty() {
1189 return Vec::new();
1190 }
1191 let mut lines = Vec::new();
1192 let mut start = 0;
1193 for (i, &byte) in content.iter().enumerate() {
1194 if byte == b'\n' {
1195 lines.push(&content[start..=i]);
1196 start = i + 1;
1197 }
1198 }
1199 if start < content.len() {
1200 lines.push(&content[start..]);
1201 }
1202 lines
1203}
1204
1205/// Calculate byte offsets for each line in content.
1206///

Callers 1

Calls 4

is_emptyMethod · 0.45
iterMethod · 0.45
pushMethod · 0.45
lenMethod · 0.45

Tested by

no test coverage detected