parallel logic for read and write

This commit is contained in:
Chris Lu 2012-12-21 02:20:38 -08:00
parent 315879ce47
commit 37afb31d05

View file

@ -90,20 +90,22 @@ func (n *Needle) readNeedleHeader(bytes []byte) {
n.Size = util.BytesToUint32(bytes[12:NeedleHeaderSize])
}
func (n *Needle) readNeedleDataVersion2(bytes []byte) {
index := 0
index, lenBytes := 0, len(bytes)
if index < lenBytes {
n.DataSize = util.BytesToUint32(bytes[index : index+4])
index = index + 4
n.Data = bytes[index : index+int(n.DataSize)]
index = index + int(n.DataSize)
n.Flags = bytes[index]
index = index + 1
if index < len(bytes) {
}
if index < lenBytes {
n.NameSize = uint8(bytes[index])
index = index + 1
n.Name = bytes[index : index+int(n.NameSize)]
index = index + int(n.NameSize)
}
if index < len(bytes) {
if index < lenBytes {
n.MimeSize = uint8(bytes[index])
index = index + 1
n.Mime = bytes[index : index+int(n.MimeSize)]