[Haskell-cafe] Performance help

Derek Elkins derek.a.elkins at gmail.com
Tue Nov 13 21:31:07 EST 2007

On Tue, 2007-11-13 at 14:21 -0800, Ryan Ingram wrote:
> On 11/13/07, Ryan Ingram <ryani.spam at gmail.com> wrote: 
>         Also, what stops getRule from going off the end of the array?
>         I didn't see anything that prevented that in the code, and
>         you're using unsafeAt, which seems like a potential bug.
> Never mind, I realized this is a ring buffer with `mod` s.   That's
> another slow operation when you're doing code as tight as this.  If
> you can guarantee the ring is a power of 2 in size you can use a mask
> instead, or use my original suggestion of deriving rules from the
> previous rule and the new bit; the initial state is determined by the
> last bits in the buffer and you never wrap.

rem is faster than mod and equivalent if everything is positive.

More information about the Haskell-Cafe mailing list