I wonder if using `*shift_table.unsafe_ref(i)` here will be faster. (This will always be safe, since `val` is 32 bits and rightshifting by 28 leaves 4 non-zero.)

Another possibility (only worth it if it gives a big improvement):

```rust
static SHIFT_TABLE_PTR: *uint = &SHIFT_TABLE[0] as *uint;
static MASK_TABLE_PTR: *uint = &MASK_TABLE[0] as *uint;

// ...

let shift = *SHIFT_TABLE_PTR.offset(i);
let mask = *MASK_TABLE_PTR.offset(i);
```

And a third possibility:

```rust
static SHIFT_MASK_TABLE: [(uint, uint), .. 16] = [
    (0, 0x0), (0, 0x0fff_ffff),
    (8, 0x1f_fff), (8, 0x1f_ffff),
    // ... 
];

// ...
let (shift, mask) = SHIFT_MASK_TABLE[i];
```

(Possibly combined with the pointer optimisation above.)

Lastly, maybe using a smaller type than `uint` for the tables might be better? `shift_table` could be bytes, and `mask_table` could be `u32`.