mirror of
https://github.com/ddidderr/wuffs.git
synced 2026-11-24 08:52:18 +01:00
Fix rac.Writer with more than 510 leaf nodes
This commit is contained in:
1 parent
a1a5b40178
commit
5cfb01a69b
2 files changed
+44
-10
No files matched your search
+25
-10
@@ -21,6 +21,13 @@ import (
|
||||
"sort"
|
||||
)
|
||||
|
||||
func btoi(b bool) int {
|
||||
if b {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func isZeroOrAPowerOf2(x uint64) bool {
|
||||
return (x & (x - 1)) == 0
|
||||
}
|
||||
@@ -656,16 +663,16 @@ func gather(nodes []node) node {
|
||||
for ; j < len(nodes); j++ {
|
||||
o := &nodes[j]
|
||||
|
||||
arity++
|
||||
if (o.secondary != 0) && !resources[o.secondary] {
|
||||
resources[o.secondary] = true
|
||||
arity++
|
||||
}
|
||||
if (o.tertiary != 0) && !resources[o.tertiary] {
|
||||
resources[o.tertiary] = true
|
||||
arity++
|
||||
}
|
||||
new2 := (o.secondary != 0) && !resources[o.secondary]
|
||||
new3 := (o.tertiary != 0) && !resources[o.tertiary]
|
||||
arity += 1 + btoi(new2) + btoi(new3)
|
||||
if arity <= 0xFF {
|
||||
if new2 {
|
||||
resources[o.secondary] = true
|
||||
}
|
||||
if new3 {
|
||||
resources[o.tertiary] = true
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -675,7 +682,15 @@ func gather(nodes []node) node {
|
||||
}
|
||||
|
||||
i = j
|
||||
arity = 0
|
||||
arity = 1
|
||||
if o.secondary != 0 {
|
||||
resources[o.secondary] = true
|
||||
arity++
|
||||
}
|
||||
if o.tertiary != 0 {
|
||||
resources[o.tertiary] = true
|
||||
arity++
|
||||
}
|
||||
}
|
||||
|
||||
if i == 0 {
|
||||
|
||||
Reference in new issue
Block a user