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)
| 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. |
| 195 | pub 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 — |
no test coverage detected