MCPcopy
hub / github.com/golang/tools / StringIdx

Method StringIdx

internal/pkgbits/encoder.go:109–119  ·  view source on GitHub ↗

StringIdx adds a string value to the strings section, if not already present, and returns its index.

(s string)

Source from the content-addressed store, hash-verified

107// StringIdx adds a string value to the strings section, if not
108// already present, and returns its index.
109func (pw *PkgEncoder) StringIdx(s string) Index {
110 if idx, ok := pw.stringsIdx[s]; ok {
111 assert(pw.elems[RelocString][idx] == s)
112 return idx
113 }
114
115 idx := Index(len(pw.elems[RelocString]))
116 pw.elems[RelocString] = append(pw.elems[RelocString], s)
117 pw.stringsIdx[s] = idx
118 return idx
119}
120
121// NewEncoder returns an Encoder for a new element within the given
122// section, and encodes the given SyncMarker as the start of the

Callers 2

SyncMethod · 0.45
StringMethod · 0.45

Calls 3

appendFunction · 0.85
assertFunction · 0.70
IndexTypeAlias · 0.70

Tested by

no test coverage detected