MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / EncodeUntaggedDecimalValue

Function EncodeUntaggedDecimalValue

pkg/util/encoding/encoding.go:1933–1946  ·  view source on GitHub ↗

EncodeUntaggedDecimalValue encodes an apd.Decimal value, appends it to the supplied buffer, and returns the final buffer.

(appendTo []byte, d *apd.Decimal)

Source from the content-addressed store, hash-verified

1931// EncodeUntaggedDecimalValue encodes an apd.Decimal value, appends it to the supplied
1932// buffer, and returns the final buffer.
1933func EncodeUntaggedDecimalValue(appendTo []byte, d *apd.Decimal) []byte {
1934 // To avoid the allocation, leave space for the varint, encode the decimal,
1935 // encode the varint, and shift the encoded decimal to the end of the
1936 // varint.
1937 varintPos := len(appendTo)
1938 // Manually append 10 (binary.MaxVarintLen64) 0s to avoid the allocation.
1939 appendTo = append(appendTo, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
1940 decOffset := len(appendTo)
1941 appendTo = EncodeNonsortingDecimal(appendTo, d)
1942 decLen := len(appendTo) - decOffset
1943 varintLen := binary.PutUvarint(appendTo[varintPos:decOffset], uint64(decLen))
1944 copy(appendTo[varintPos+varintLen:varintPos+varintLen+decLen], appendTo[decOffset:decOffset+decLen])
1945 return appendTo[:varintPos+varintLen+decLen]
1946}
1947
1948// EncodeDurationValue encodes a duration.Duration value with its value tag,
1949// appends it to the supplied buffer, and returns the final buffer.

Callers 2

encodeMethod · 0.92
EncodeDecimalValueFunction · 0.85

Calls 1

EncodeNonsortingDecimalFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…