Remove cap tricks, use address comparison for subslice offset
Replace cap(parent) - cap(subslice) with a straightforward scan that compares element addresses: &data[i] == &subslice[0]. This is well-defined Go pointer comparison on elements of the same backing array, with no dependency on capacity semantics, reflect, or unsafe. The scan is O(n) but only runs on error paths, and TOML documents are small per the project's design constraints. Also remove the Offset field from ParserError and the setErrOffset machinery — the offset is computed at the point of consumption (wrapDecodeError, Parser.Range) rather than cached on the error. Co-authored-by: Thomas Pelletier <thomas@pelletier.dev>
This commit is contained in:
@@ -172,7 +172,6 @@ line 5`,
|
||||
err := wrapDecodeError(doc, &unstable.ParserError{
|
||||
Highlight: hl,
|
||||
Message: e.msg,
|
||||
Offset: start,
|
||||
})
|
||||
|
||||
var derr *DecodeError
|
||||
|
||||
Reference in New Issue
Block a user