berkshelf/solve — pull request #32 by sethvargo (2014-03-31 04:40:39+00:00)
Title: Resolver speed optimizations

Tiny little things that made a significant speed improvement:

- Use `Array#values` instead of collecting the key. This creates a new data structure and iterator instead of just calling `values`.
- Cache the "default constraint" object. In examining the object space, we were creating the `>= 0.0.0` constraint **millions** of times being it's the default.
- Create `Constraint.coerce` class method that takes a String or Constraint object. Moving this to a class method not only ensures consistency, but the Ruby VM can actually cache the results of the coercion.
- (**Breaking**) The `Graph#artifacts` method was entirely too overloaded. There were millions of unnecessary comparisons happening on objects where two methods are really appropriate. There is now a `Graph#artifact` and `Graph#artifacts` which matches a more Ruby approach and avoids unnecessary computation.
- Hold a secondary cache of `artifacts_by_name` for a much quicker lookup when calling `#versions`. This increased memory usage by a small percentage (~0.03%), but drastically reduced lookup times, since the previous implementation required iterating over the entire collection.
- Add a new `universe` class (currently unused and a WIP)