MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / emit_blank

Function emit_blank

codegraph-kernel/src/cfnptr.rs:271–297  ·  view source on GitHub ↗

One space per UTF-16 code unit (`\n` preserved): ASCII and 2-3-byte chars are one unit, 4-byte (astral) chars are a surrogate pair — two units.

(out: &mut Vec<u8>, region: &[u8])

Source from the content-addressed store, hash-verified

269
270/// One space per UTF-16 code unit (`\n` preserved): ASCII and 2-3-byte chars
271/// are one unit, 4-byte (astral) chars are a surrogate pair — two units.
272fn emit_blank(out: &mut Vec<u8>, region: &[u8]) {
273 let mut i = 0;
274 while i < region.len() {
275 let b = region[i];
276 if b == b'\n' {
277 out.push(b'\n');
278 i += 1;
279 continue;
280 }
281 let len = if b < 0x80 {
282 1
283 } else if b < 0xC0 {
284 1 // continuation byte at region start — invalid UTF-8; count singly
285 } else if b < 0xE0 {
286 2
287 } else if b < 0xF0 {
288 3
289 } else {
290 4
291 };
292 out.push(b' ');
293 if len == 4 {
294 out.push(b' ');
295 }
296 i += len.min(region.len() - i);
297 }
298}
299
300// ---------- shared regex tails ----------

Callers 1

strip_cFunction · 0.85

Calls 1

lenMethod · 0.80

Tested by

no test coverage detected