With this BoolSeq, i can get a speedup, at the cost of slower assignment
type
BoolSeq = object
data: seq[set[uint8]]
func newBoolSeq(length:int):BoolSeq =
result.data = newSeq[set[uint8]](length div 256 + 1)
func `[]`*(b:BoolSeq,idx:int):bool{.inline.} =
(idx mod 256).uint8 in b.data[idx div 256]
func `[]=`*(b:var BoolSeq,idx:int,val:bool){.inline.} =
let
x = idx div 256
y = uint8(idx mod 256)
if val:
b.data[x].incl y
else:
b.data[x].excl y
Run
the other technique that helped a bit was not using a 2d coordinate system. all
those multiplications ain't free.
* Generation: master: 6.7-7.1ms this: 9.4-10.7
* Cold: master: 15.0-15.9ms this: 5.8-7.0
* Hot: master: 14.1-14.4ms this: 5.5-5.9ms
<https://github.com/avahe-kellenberger/maze_bench_nim/pull/2>