JuliaLang/julia — pull request #4663 by carlobaldassi (2013-10-28 00:37:50+00:00)
Title: Complete multidimensional bounds checks for BitArrays and more

This completes bounds checks for multidimensional BitArrays, e.g. it is no longer valid to index a 2x4 BitArray `B` with `B[1,5]` or `B[3,1]`, which result in a `BoundsError`. Therefore, they now behave like Arrays, at least from what I can tell.
The cost in performance is at most 10% in my tests, i.e. the new code is within 1.1x of the old code (in most cases less, around 3%). However, I had to manually inline a bunch of stuff in certain cases to get there (the non-inlined versions were more like 3x to 4x slower then the old code in my tests) . I think some code ugliness is a fair price to pay to get both safety and decent performance in this case though.

In addition to this, there are a couple of other commits:

* I merged the internal `indices` function into the `to_index` function, since they seemed to be largely overlapping, and I added some more functionality; the name `to_index` may be slightly misleading though, but I think it's a minor problem.
* I restricted some signatures of the `checkbounds` function, otherwise some methods were never being called, and simplified some of the code.