Skip to content

Commit

Permalink
More improvements to the DFA's inner loop.
Browse files Browse the repository at this point in the history
There were two important changes:

  1. self.at is used sparingly in favor of a local `let at` binding.
     This seems to convince the compiler to use a register.
  2. Switch the transition table from a `Vec<Box<[StatePtr]>>` to a
     row-major `Vec<StatePtr>`.

(2) is the juicier of the two. It makes more efficient use of the cache.
In particular, a critical aspect is that a StatePtr points to the start
of a row in the table, which enables indexing in the inner loop with a
single ADD instruction. (i.e., `si + byte` instead of
`si * #classes + byte`.)
  • Loading branch information
BurntSushi committed Apr 22, 2016
1 parent 66ad2c4 commit 09d1766
Show file tree
Hide file tree
Showing 2 changed files with 326 additions and 227 deletions.
Loading

0 comments on commit 09d1766

Please sign in to comment.