diff options
author | Christian Hofstaedtler <c.hofstaedtler@efficientcloud.com> | 2011-07-06 14:40:28 +0200 |
---|---|---|
committer | Christian Hofstaedtler <c.hofstaedtler@efficientcloud.com> | 2011-07-06 14:41:50 +0200 |
commit | 9f21b23e58e793c78a38d7a9e5676ce34bc08e8c (patch) | |
tree | 7403672c0e627cbd30cf62bee9211ea3fc2adb63 /lib | |
parent | 68ad8d4166d03c04b5b2cfe992df961ebadc8751 (diff) | |
download | bundler-9f21b23e58e793c78a38d7a9e5676ce34bc08e8c.tar.gz |
Performance fix for MRI 1.9
MRI 1.9 is considerably faster when directly comparing Gem::Version,
while 1.8 is faster with the regex method.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/index.rb | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/lib/bundler/index.rb b/lib/bundler/index.rb index 4d7f7725..375bb276 100644 --- a/lib/bundler/index.rb +++ b/lib/bundler/index.rb @@ -101,10 +101,15 @@ module Bundler end end - def same_version?(a, b) - regex = /^(.*?)(?:\.0)*$/ - - a.to_s[regex, 1] == b.to_s[regex, 1] + if RUBY_VERSION < '1.9' + def same_version?(a, b) + regex = /^(.*?)(?:\.0)*$/ + a.to_s[regex, 1] == b.to_s[regex, 1] + end + else + def same_version?(a, b) + a == b + end end def spec_satisfies_dependency?(spec, dep) |