Btree doesn't have to be a 'ref object'

This commit is contained in:
Andreas Rumpf 2017-05-12 17:11:37 +02:00
commit e300692c75

View file

@ -16,7 +16,7 @@ type
vals: array[M, Val] vals: array[M, Val]
of true: of true:
links: array[M, Node] links: array[M, Node]
BTree = ref object BTree = object
root: Node root: Node
height: int ## height height: int ## height
n: int ## number of key-value pairs n: int ## number of key-value pairs
@ -87,7 +87,7 @@ proc insert(h: Node, key: Key, val: Val, ht: int): Node =
inc h.m inc h.m
return if h.m < M: nil else: split(h) return if h.m < M: nil else: split(h)
proc put(b: BTree; key: Key; val: Val) = proc put(b: var BTree; key: Key; val: Val) =
let u = insert(b.root, key, val, b.height) let u = insert(b.root, key, val, b.height)
inc b.n inc b.n
if u == nil: return if u == nil: return