Cache Gem::Version instances for each version string

This prevents having numerous instances of the same value object. In
particular, the use of String#scan in Version#segments is a hot spot. We
could perform the caching there but it seems reasonable to cache the
entire object.
Implement Gem::Specification#to_ary

This is a perf fix. Array#flatten is called in places which contain
nested arrays of spec objects. (For example in
Gem::Specification.find_in_unresolved.) Due to Ruby's implementation of
Array#flatten, it will hit method_missing to try to dispatch the #to_ary
method, which is slow. Implementing a #to_ary like this prevents
method_missing getting called.
Merge pull request #447 from jonleighton/perf_tweaks

Perf tweaks