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

Function col16

codegraph-kernel/src/textutil.rs:195–201  ·  view source on GitHub ↗

Column (UTF-16 units) of `byte_pos` on line `row`, given `line_starts`. Read from the table: the bytes from the line's start, less those that count for no unit. Counted character by character from the line's start for every symbol and reference, a script minified to one line took the square of its length: a megabyte, a minute. The source is no longer read; the parameter stays so every caller is a

(_src: &str, starts: &LineStarts, row: usize, byte_pos: usize)

Source from the content-addressed store, hash-verified

193/// square of its length: a megabyte, a minute.
194/// The source is no longer read; the parameter stays so every caller is as it was.
195pub fn col16(_src: &str, starts: &LineStarts, row: usize, byte_pos: usize) -> u32 {
196 let ls = starts.get(row).copied().unwrap_or(0);
197 if byte_pos <= ls {
198 return 0;
199 }
200 (byte_pos - ls - (starts.spare_before(byte_pos) - starts.spare_before(ls))) as u32
201}
202
203/// JS `String.prototype.slice(0, n)` in UTF-16 units, without splitting a
204/// surrogate pair (when the cut would split one, we stop one code unit short —

Callers 15

col_ofMethod · 0.85
end_col_ofMethod · 0.85
col_ofMethod · 0.85
end_col_ofMethod · 0.85
col_ofMethod · 0.85
end_col_ofMethod · 0.85
col_ofMethod · 0.85
end_col_ofMethod · 0.85

Calls 2

spare_beforeMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected