+ if int(tag) >= len(tilelib.variant) {
+ // If we haven't seen the tag library yet (as in a
+ // merge), tilelib.taglib.Len() is zero. We can still
+ // behave correctly, we just need to expand the
+ // tilelib.variant slice as needed.
+ if int(tag) >= cap(tilelib.variant) {
+ // Allocate 2x capacity.
+ newslice := make([][][blake2b.Size256]byte, int(tag)+1, (int(tag)+1)*2)
+ copy(newslice, tilelib.variant)
+ tilelib.variant = newslice[:int(tag)+1]
+ } else {
+ // Use previously allocated capacity, avoiding
+ // copy.
+ tilelib.variant = tilelib.variant[:int(tag)+1]
+ }
+ }