// SerializeSize returns the number of bytes it would take to serialize the the
// transaction input's witness.
496171
func (t TxWitness) SerializeSize() int {
	// A varint to signal the number of elements the witness has.
	n := VarIntSerializeSize(uint64(len(t)))

	// For each element in the witness, we'll need a varint to signal the
	// size of the element, then finally the number of bytes the element
	// itself comprises.
	for _, witItem := range t {
		n += VarIntSerializeSize(uint64(len(witItem)))
		n += len(witItem)
	}

	return n
}
341897
func serializeSig(sig *secp256k1.Signature) []byte {
	rBytes := sig.R.Bytes()
	sBytes := sig.S.Bytes()
	sigBytes := make([]byte, 64)
	// 0 pad the byte arrays from the left if they aren't big enough.
	copy(sigBytes[32-len(rBytes):32], rBytes)
	copy(sigBytes[64-len(sBytes):64], sBytes)
	return sigBytes
}
127417
func (b *GetLabelChunkBody) Serialize(version uint8) ([]byte, error) {
	buf := make([]byte, 8)
	pos := 0
	if version > 4 {
		buf[pos] = b.Proto
		binary.BigEndian.PutUint16(buf[pos+1:pos+3], b.Instance)
		pos += 3
	}
	buf[pos] = b.Keep
	binary.BigEndian.PutUint32(buf[pos+1:pos+5], b.ChunkSize)
	pos += 5
	return buf[0:pos], nil
}
21956
func Serialize(s Serializer) (string, error) {
	w := &standardWriter{}
	if err := s.Serialize(w); err != nil {
		return "", err
	}
	return w.String(), nil
}
266792
func (udh *UDH) SerializeTo(w io.Writer) error {
	_, err := w.Write(udh.Bytes())
	return err
}
140082
func (b *LabelManagerConnectBody) Serialize(version uint8) ([]byte, error) {
	buf := make([]byte, 3)
	buf[0] = uint8(b.RedistDefault)
	binary.BigEndian.PutUint16(buf[1:3], b.Instance)
	return buf, nil
}
588048
func (v *Variable) SerializeTo(w io.Writer) error {
	_, err := w.Write(v.Bytes())
	return err
}
680180
func Serialize(inf *info.CPUInfo) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Serialize(inf), nil
}
237811
func Serialize(st *structs.DiskStats) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Serialize(st)
}
252684
func (msg *Message) Serialize() []byte {
	msg.DataLen = msgLenToBytes(int64(len(msg.Data)))
	buf := bytes.NewBuffer([]byte{})
	binary.Write(buf, binary.BigEndian, msg.MessageHeader)
	binary.Write(buf, binary.BigEndian, msg.Data[:])

	return buf.Bytes()
}
75646
func (ba *sparseBitArray) Serialize() ([]byte, error) {
	w := new(bytes.Buffer)

	var identifier uint8 = 'S'
	err := binary.Write(w, binary.LittleEndian, identifier)
	if err != nil {
		return nil, err
	}

	blocksLen := uint64(len(ba.blocks))
	indexLen := uint64(len(ba.indices))

	err = binary.Write(w, binary.LittleEndian, blocksLen)
	if err != nil {
		return nil, err
	}

	err = binary.Write(w, binary.LittleEndian, ba.blocks)
	if err != nil {
		return nil, err
	}

	err = binary.Write(w, binary.LittleEndian, indexLen)
	if err != nil {
		return nil, err
	}

	err = binary.Write(w, binary.LittleEndian, ba.indices)
	if err != nil {
		return nil, err
	}
	return w.Bytes(), nil
}
945330
func (s *storeImpl) Size() int {
	s.mutex.RLock()
	defer s.mutex.RUnlock()
	return len(s.objects)
}
691838
func (e *Serializer) Serialize(val interface{}, options ...map[string]interface{}) ([]byte, error) {
	if e.config.StreamingJSON {
		w := buffer.Get()
		if len(e.config.Prefix) > 0 {
			w.Write(e.config.Prefix)
		}
		err := json.NewEncoder(w).Encode(val)
		result := w.Bytes()
		buffer.Put(w)
		return result, err
	}

	var result []byte
	var err error

	if e.config.Indent {
		result, err = json.MarshalIndent(val, "", "  ")
		result = append(result, newLineB...)
	} else {
		result, err = json.Marshal(val)
	}
	if err != nil {
		return nil, err
	}

	if e.config.UnEscapeHTML {
		result = bytes.Replace(result, ltHex, lt, -1)
		result = bytes.Replace(result, gtHex, gt, -1)
		result = bytes.Replace(result, andHex, and, -1)
	}
	if len(e.config.Prefix) > 0 {
		result = append(e.config.Prefix, result...)
	}
	return result, nil
}
1233583
func (key *Key) Serialize() ([]byte, error) {
	// Private keys should be prepended with a single null byte
	keyBytes := key.Key
	if key.IsPrivate {
		keyBytes = append([]byte{0x0}, keyBytes...)
	}

	// Write fields to buffer in order
	buffer := new(bytes.Buffer)
	buffer.Write(key.Version)
	buffer.WriteByte(key.Depth)
	buffer.Write(key.FingerPrint)
	buffer.Write(key.ChildNumber)
	buffer.Write(key.ChainCode)
	buffer.Write(keyBytes)

	// Append the standard doublesha256 checksum
	serializedKey, err := addChecksumToBytes(buffer.Bytes())
	if err != nil {
		return nil, err
	}

	return serializedKey, nil
}
778635
func Serialize(u *util.CPUUtil) (p []byte, err error) {
	stdMu.Lock()
	defer stdMu.Unlock()
	if std == nil {
		std, err = NewProfiler()
		if err != nil {
			return nil, err
		}
	}
	return std.Serialize(u), nil
}
23239
func (e *Serializer) Serialize(val interface{}, options ...map[string]interface{}) ([]byte, error) {
	var b []byte
	if s, isString := val.(string); isString {
		b = []byte(s)
	} else {
		b = val.([]byte)
	}
	buf := blackfriday.MarkdownCommon(b)
	if e.config.MarkdownSanitize {
		buf = bluemonday.UGCPolicy().SanitizeBytes(buf)
	}

	return buf, nil
}
810801
func (p *PrivateKey) Serialize() []byte {
	b := make([]byte, 0, PrivKeyBytesLen)
	return paddedAppend(PrivKeyBytesLen, b, p.ToECDSA().D.Bytes())
}