Skip to content

Commit 690d3ef

Browse files
PMunchfrol
authored andcommitted
Use tuple instead of object for a small speedup
1 parent 86235b4 commit 690d3ef

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

nim/main.nim

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,17 +39,10 @@ proc splitBinary(orig: Node, value: int): (Node, Node) =
3939
proc merge3(lower: Node, equal: Node, greater: Node): Node =
4040
return merge(merge(lower, equal), greater)
4141

42-
43-
type SplitResult = object
44-
lower: Node
45-
equal: Node
46-
greater: Node
47-
48-
49-
proc split(orig: Node, value: int): SplitResult =
42+
proc split(orig: Node, value: int): tuple[lower, equal, greater: Node] =
5043
let (lower, equalGreater) = splitBinary(orig, value)
5144
let (equal, greater) = splitBinary(equalGreater, value + 1)
52-
return SplitResult(lower: lower, equal: equal, greater: greater)
45+
return (lower: lower, equal: equal, greater: greater)
5346

5447

5548
type Tree = ref object

0 commit comments

Comments
 (0)