Skip to content

Commit a61b3d4

Browse files
committed
neigbors: inline iterator instead of array to avoid memset and genericReset
1 parent f050a78 commit a61b3d4

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/datatypes.nim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,11 @@ const MaxNbMoves* = 512
152152

153153
################################ Go common logic ###################################
154154

155-
func neighbors*[N: static[int8]](idx: Point[N]): array[4, Point[N]] {.inline.}=
156-
[Point[N] idx.int16 - 1, Point[N] idx.int16 + 1, Point[N] idx.int16 - (N+2), Point[N] idx.int16 + (N+2)]
155+
iterator neighbors*[N: static[int8]](idx: Point[N]):Point[N] =
156+
yield Point[N] idx.int16 - 1
157+
yield Point[N] idx.int16 + 1
158+
yield Point[N] idx.int16 - (N+2)
159+
yield Point[N] idx.int16 + (N+2)
157160

158161
const opponents: array[Player, Player] = [
159162
Black: Player White,

0 commit comments

Comments
 (0)