mirror of
https://github.com/dolthub/dolt.git
synced 2026-02-05 10:31:30 -06:00
Code review cleanup
This commit is contained in:
@@ -172,14 +172,17 @@ func jsonDecodeCompoundBlob(input []interface{}, cs chunks.ChunkSource) (Future,
|
||||
return nil, errInvalidEncoding
|
||||
}
|
||||
|
||||
var err error
|
||||
i := 0
|
||||
length, err := toUint64(input[len(input)-1])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
numBlobs := len(input) / 2
|
||||
offsets := make([]uint64, numBlobs)
|
||||
blobs := make([]Future, numBlobs)
|
||||
|
||||
for i < len(input)-1 {
|
||||
for i := 0; i < len(input)-1; i++ {
|
||||
var err error
|
||||
var offset uint64
|
||||
if i == 0 {
|
||||
offset = uint64(0)
|
||||
@@ -192,18 +195,11 @@ func jsonDecodeCompoundBlob(input []interface{}, cs chunks.ChunkSource) (Future,
|
||||
}
|
||||
offsets[i/2] = offset
|
||||
blobs[i/2], err = jsonDecodeValue(input[i], cs)
|
||||
i++
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
length, err := toUint64(input[i])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
Chk.Equal(len(input), i+1)
|
||||
|
||||
cb := compoundBlob{length, offsets, blobs, &ref.Ref{}, cs}
|
||||
return futureFromValue(cb), nil
|
||||
}
|
||||
|
||||
@@ -166,22 +166,20 @@ func getChildJSON(f Future, s chunks.ChunkSink) (interface{}, error) {
|
||||
func getJSONCompoundBlob(cb compoundBlob, s chunks.ChunkSink) (interface{}, error) {
|
||||
// {"cb":[{"ref":"sha1-x"},length]}
|
||||
// {"cb":[{"ref":"sha1-x"},offset,{"ref":"sha1-y"},length]}
|
||||
var err error
|
||||
l := make([]interface{}, len(cb.blobs)*2)
|
||||
j := 0
|
||||
l := make([]interface{}, 0, len(cb.blobs)*2)
|
||||
for i, f := range cb.blobs {
|
||||
if i != 0 {
|
||||
l[j] = cb.offsets[i]
|
||||
j++
|
||||
l = append(l, cb.offsets[i])
|
||||
}
|
||||
if l[j], err = getChildJSON(f, s); err != nil {
|
||||
c, err := getChildJSON(f, s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
j++
|
||||
l = append(l, c)
|
||||
}
|
||||
l[j] = cb.length
|
||||
l = append(l, cb.length)
|
||||
|
||||
Chk.Equal(len(l), j+1)
|
||||
Chk.Equal(len(l), len(cb.blobs)*2)
|
||||
|
||||
return map[string]interface{}{
|
||||
"cb": l,
|
||||
|
||||
Reference in New Issue
Block a user