rubygems/rubygems — pull request #843 by tenderlove (2014-03-06 00:01:11+00:00)
Title: only check conflicts for specs that can actually be activated

This commit separates the "a different version of this gem has already
been loaded" check from the "this gem has conflicts" check.

Merits:

* We only have to look up the spec once rather than twice:

https://github.com/rubygems/rubygems/blob/f235c4a5f1e27369f9cf800b01092adc68216a53/lib/rubygems/specification.rb#L1264
https://github.com/rubygems/rubygems/blob/f235c4a5f1e27369f9cf800b01092adc68216a53/lib/rubygems/specification.rb#L2053

* We only have to check existence of the spec once rather than twice:

https://github.com/rubygems/rubygems/blob/f235c4a5f1e27369f9cf800b01092adc68216a53/lib/rubygems/specification.rb#L2055
https://github.com/rubygems/rubygems/blob/f235c4a5f1e27369f9cf800b01092adc68216a53/lib/rubygems/specification.rb#L1264

* We don't need to check for conflicts on this gem because we aren't
going to load it anyway.

Demerits:

* It seems that basically all methods in Gem::Specification are public,
so its impossible to tell what is safe to refactor. This technically
changes the behavior of `raise_if_conflicts`, so if people are manually
instantiating specs and calling that method then it will not behave the
same. If this method were private, we wouldn't have to worry so much.