Skip to content

Commit 4bfb611

Browse files
authored
Merge pull request #27 from Galaco/refactor
Refactor
2 parents 208dcd7 + 26a12a6 commit 4bfb611

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lumps/leaf.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ func (lump *Leaf) Unmarshall(raw []byte) (err error) {
4242
i := 0
4343

4444
for i < numLeafs {
45-
rawLeaf := bytes.NewBuffer(raw[(structSize * i) : (structSize*i)+structSize])
45+
leafBuf := make([]byte, structSize)
46+
copy(leafBuf, raw[(structSize * i) : (structSize*i)+structSize])
4647
// Pad the raw data to the correct size of a leaf
4748
if lump.Version() > maxBspVersionOfV0Leaf {
48-
rawLeaf.Write(make([]byte, int(unsafe.Sizeof(common.CompressedLightCube{}))))
49+
leafBuf = append(leafBuf, make([]byte, int(unsafe.Sizeof(common.CompressedLightCube{})))...)
4950
}
51+
rawLeaf := bytes.NewBuffer(leafBuf)
5052
err = binary.Read(rawLeaf, binary.LittleEndian, &lump.data[i])
5153
if err != nil {
5254
return err

0 commit comments

Comments
 (0)