sourcegraph/internal/byteutils
Camden Cheek 5d8286b90f
Backend: add line index (#63726)
This adds a line index utility. Frequently, I want to be able to
efficiently index a file to extract a specific line or range of lines,
but it's surprisingly tricky to get exactly right given weird
definitions of "what even is a line" and edge conditions around
out-of-bounds and such.

So this adds a general-purpose utility to pre-calculate the locations of
lines in the file, making extracting a line range a zero-allocation,
`O(1)` operation.

Not implemented: the same index can also be used to find the line that
contains an offset, which I've also needed to do before. But I'll save
that for when I actually have an immediate use for it.
2024-07-09 19:59:42 +00:00
..
BUILD.bazel Backend: add line index (#63726) 2024-07-09 19:59:42 +00:00
lineindex_test.go Backend: add line index (#63726) 2024-07-09 19:59:42 +00:00
lineindex.go Backend: add line index (#63726) 2024-07-09 19:59:42 +00:00
linereader_test.go Replace all traditional for-loops (#60988) 2024-03-11 16:05:47 +02:00
linereader.go Add linereader helper (#49965) 2023-03-24 17:39:49 +01:00
nullscanner.go [gitserver] ArchiveReader correctly handles paths with spaces (#61522) 2024-04-02 15:39:55 +02:00