Skip to content

Commit

Permalink
paths: do not allocate byte slices; use unsigned varints
Browse files Browse the repository at this point in the history
Signed-off-by: Vicent Marti <vmg@strn.cat>
  • Loading branch information
vmg committed Feb 11, 2025
1 parent f46418c commit 2528cf3
Show file tree
Hide file tree
Showing 5 changed files with 91 additions and 75 deletions.
2 changes: 1 addition & 1 deletion go/tools/asthelpergen/paths_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ func (p *pathGen) generateWalkCases(spi generatorSPI) []jen.Code {
}

cases = append(cases, jen.Case(jen.Id(stepName+"Offset")).Block(
jen.Id("idx, bytesRead").Op(":=").Qual("encoding/binary", "Varint").Call(jen.Index().Byte().Parens(jen.Id("path"))),
jen.Id("idx, bytesRead").Op(":=").Id("nextPathOffset").Call(jen.Id("path")),
jen.Id("path").Op("=").Id("path[bytesRead:]"),
jen.Return(jen.Id("GetNodeFromPath").Call(assignNode, jen.Id("path"))),
))
Expand Down
Loading

0 comments on commit 2528cf3

Please sign in to comment.