aboutsummaryrefslogtreecommitdiff
path: root/node.go
diff options
context:
space:
mode:
Diffstat (limited to 'node.go')
-rw-r--r--node.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/node.go b/node.go
index 05aefb8..4276e4a 100644
--- a/node.go
+++ b/node.go
@@ -220,12 +220,16 @@ func (n *node) write(p *page) {
elem.pgid = item.pgid
_assert(elem.pgid != p.id, "write: circular dependency occurred")
}
+ lk, lv := len(item.key), len(item.value)
+ if len(b) < lk+lv {
+ b = (*[maxAllocSize]byte)(unsafe.Pointer(&b[0]))[:]
+ }
// Write data for the element to the end of the page.
copy(b[0:], item.key)
- b = b[len(item.key):]
+ b = b[lk:]
copy(b[0:], item.value)
- b = b[len(item.value):]
+ b = b[lv:]
}
// DEBUG ONLY: n.dump()
@@ -351,7 +355,9 @@ func (n *node) spill() error {
}
// Allocate contiguous space for the node.
- p, err := tx.allocate((node.size() / tx.db.pageSize) + 1)
+ // sz := node.size() + n.pageElementSize()*len(n.inodes)
+ sz := node.size()
+ p, err := tx.allocate((sz / tx.db.pageSize) + 1)
if err != nil {
return err
}