MCPcopy Index your code
hub / github.com/microsoft/typescript-go / allocNodeSlice

Method allocNodeSlice

internal/api/encoder/decoder.go:100–104  ·  view source on GitHub ↗

allocNodeSlice returns a zero-length slice with the given capacity, backed by the pre-allocated nodeArena. This avoids a heap allocation per NodeList.

(capacity int)

Source from the content-addressed store, hash-verified

98// allocNodeSlice returns a zero-length slice with the given capacity, backed by
99// the pre-allocated nodeArena. This avoids a heap allocation per NodeList.
100func (d *astDecoder) allocNodeSlice(capacity int) []*ast.Node {
101 start := len(d.nodeArena)
102 d.nodeArena = d.nodeArena[:start+capacity]
103 return d.nodeArena[start : start : start+capacity]
104}
105
106// nodeField reads a uint32 field from node i at the given field offset.
107func (d *astDecoder) nodeField(i int, field int) uint32 {

Callers 2

decodeMethod · 0.95
createChildrenNodeMethod · 0.95

Calls 1

lenFunction · 0.85

Tested by

no test coverage detected