I would like to point out, that it is really the **const seq** which is causing 
most of the slowdown in the original version (and a const seq does not make 
much sense, if you think about it and should maybe be complained about by the 
compiler). If you use a var seq instead, the difference to the var array is 
much less pronounced. This takes 0.9 sec for 1_000_000 iterations: 
    
    
    var NE = @[8, 2, 13, 4, 5, 7, 8, 3, 9, 12, 7, 8, 3, 9, 12]
    var Directions = [NE, NE, NE, NE]
    

while this takes 0.6 sec: 
    
    
    var NE = [8, 2, 13, 4, 5, 7, 8, 3, 9, 12, 7, 8, 3, 9, 12]
    var Directions = [NE, NE, NE, NE]
    

Compare this to 11 vs. 1 sec for the const case mentioned earlier.

Reply via email to