Remove Parser.Range and subsliceOffset
Range() existed to recover byte offsets from Highlight subslices. Now that ParserError carries an explicit Offset field, Range() is unnecessary. Remove it along with the private subsliceOffset helper in ast.go. Tests now use perr.Offset directly and construct Range literals for Shape() calls. Co-authored-by: Thomas Pelletier <thomas@pelletier.dev>
This commit is contained in:
@@ -90,18 +90,6 @@ type Range struct {
|
||||
Length uint32
|
||||
}
|
||||
|
||||
func subsliceOffset(data []byte, subslice []byte) int {
|
||||
if len(subslice) == 0 {
|
||||
return len(data)
|
||||
}
|
||||
for i := range data {
|
||||
if &data[i] == &subslice[0] {
|
||||
return i
|
||||
}
|
||||
}
|
||||
panic("subslice is not within data")
|
||||
}
|
||||
|
||||
// Next returns a pointer to the next node, or nil if there is no next node.
|
||||
func (n *Node) Next() *Node {
|
||||
if n.next < 0 {
|
||||
|
||||
Reference in New Issue
Block a user