MCPcopy
hub / github.com/etcd-io/bbolt / sizeLessThan

Method sizeLessThan

node.go:53–63  ·  view source on GitHub ↗

sizeLessThan returns true if the node is less than a given size. This is an optimization to avoid calculating a large node when we only need to know if it fits inside a certain page size.

(v uintptr)

Source from the content-addressed store, hash-verified

51// This is an optimization to avoid calculating a large node when we only need
52// to know if it fits inside a certain page size.
53func (n *node) sizeLessThan(v uintptr) bool {
54 sz, elsz := common.PageHeaderSize, n.pageElementSize()
55 for i := 0; i < len(n.inodes); i++ {
56 item := &n.inodes[i]
57 sz += elsz + uintptr(len(item.Key())) + uintptr(len(item.Value()))
58 if sz >= v {
59 return false
60 }
61 }
62 return true
63}
64
65// pageElementSize returns the size of each page element based on the type of node.
66func (n *node) pageElementSize() uintptr {

Callers 1

splitTwoMethod · 0.95

Calls 3

pageElementSizeMethod · 0.95
KeyMethod · 0.45
ValueMethod · 0.45

Tested by

no test coverage detected