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

Function copyWords

pkg/util/encoding/decimal.go:745–762  ·  view source on GitHub ↗

copyWords was adapted from math/big/nat.go. It writes the value of nat into buf using big-endian encoding. len(buf) must be >= len(nat)*bigWordSize.

(buf []byte, nat []big.Word)

Source from the content-addressed store, hash-verified

743// copyWords was adapted from math/big/nat.go. It writes the value of
744// nat into buf using big-endian encoding. len(buf) must be >= len(nat)*bigWordSize.
745func copyWords(buf []byte, nat []big.Word) []byte {
746 // Omit leading zeros from the resulting byte slice, which is both
747 // safe and exactly what big.Int.Bytes() does. See big.nat.setBytes()
748 // and big.nat.norm() for how this is normalized on decoding.
749 leading := true
750 for w := len(nat) - 1; w >= 0; w-- {
751 d := nat[w]
752 for j := bigWordSize - 1; j >= 0; j-- {
753 by := byte(d >> (8 * big.Word(j)))
754 if by == 0 && leading {
755 continue
756 }
757 leading = false
758 buf = append(buf, by)
759 }
760 }
761 return buf
762}

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…