Add some fast-paths for equality checks.

We do some equality checks on Indexes occasionally, and it is nice to be able to avoid a full traversal where possible.