Store package ref list in separate entity and load it only on demand.

This commit is contained in:
Andrey Smirnov
2013-12-20 16:38:50 +04:00
parent 7940f5e698
commit e4defeb2fd
5 changed files with 169 additions and 11 deletions
+17
View File
@@ -3,6 +3,7 @@ package debian
import (
"bytes"
"fmt"
"github.com/ugorji/go/codec"
"sort"
)
@@ -86,3 +87,19 @@ func (l *PackageRefList) Swap(i, j int) {
func (l *PackageRefList) Less(i, j int) bool {
return bytes.Compare(l.Refs[i], l.Refs[j]) < 0
}
// Encode does msgpack encoding of PackageRefList
func (l *PackageRefList) Encode() []byte {
var buf bytes.Buffer
encoder := codec.NewEncoder(&buf, &codec.MsgpackHandle{})
encoder.Encode(l)
return buf.Bytes()
}
// Decode decodes msgpack representation into PackageRefLit
func (l *PackageRefList) Decode(input []byte) error {
decoder := codec.NewDecoderBytes(input, &codec.MsgpackHandle{})
return decoder.Decode(l)
}