Speed optimizations and one bug fix.

* Added shortcut comparisons when protocols are equal.
* Adapters are registered by from_protocol name, so that we can quickly
  get rid of edges that do not match the current object type
* Fixed a bug in the sort comparison function.