split breaks up a node into multiple smaller nodes, if appropriate. This should only be called from the spill() function.
(pageSize uintptr)
| 204 | // split breaks up a node into multiple smaller nodes, if appropriate. |
| 205 | // This should only be called from the spill() function. |
| 206 | func (n *node) split(pageSize uintptr) []*node { |
| 207 | var nodes []*node |
| 208 | |
| 209 | node := n |
| 210 | for { |
| 211 | // Split node into two. |
| 212 | a, b := node.splitTwo(pageSize) |
| 213 | nodes = append(nodes, a) |
| 214 | |
| 215 | // If we can't split then exit the loop. |
| 216 | if b == nil { |
| 217 | break |
| 218 | } |
| 219 | |
| 220 | // Set node to b so it gets split on the next iteration. |
| 221 | node = b |
| 222 | } |
| 223 | |
| 224 | return nodes |
| 225 | } |
| 226 | |
| 227 | // splitTwo breaks up a node into two smaller nodes, if appropriate. |
| 228 | // This should only be called from the split() function. |