Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Change `sort` calls to `sort_by` for optimization.

Signed-off-by: David Celis <david@davidcelis.com>
  • Loading branch information...
commit d83e955b79288e87fbcc2484a3c6a6f8f1090184 1 parent 3703a19
@davidcelis authored
View
50 Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- recommendable (1.1.5)
+ recommendable (1.1.6)
hooks (>= 0.2.1)
rails (>= 3.0.0)
redis (>= 2.2.0)
@@ -9,12 +9,12 @@ PATH
GEM
remote: http://rubygems.org/
specs:
- actionmailer (3.2.7)
- actionpack (= 3.2.7)
+ actionmailer (3.2.8)
+ actionpack (= 3.2.8)
mail (~> 2.4.4)
- actionpack (3.2.7)
- activemodel (= 3.2.7)
- activesupport (= 3.2.7)
+ actionpack (3.2.8)
+ activemodel (= 3.2.8)
+ activesupport (= 3.2.8)
builder (~> 3.0.0)
erubis (~> 2.7.0)
journey (~> 1.0.4)
@@ -22,18 +22,18 @@ GEM
rack-cache (~> 1.2)
rack-test (~> 0.6.1)
sprockets (~> 2.1.3)
- activemodel (3.2.7)
- activesupport (= 3.2.7)
+ activemodel (3.2.8)
+ activesupport (= 3.2.8)
builder (~> 3.0.0)
- activerecord (3.2.7)
- activemodel (= 3.2.7)
- activesupport (= 3.2.7)
+ activerecord (3.2.8)
+ activemodel (= 3.2.8)
+ activesupport (= 3.2.8)
arel (~> 3.0.2)
tzinfo (~> 0.3.29)
- activeresource (3.2.7)
- activemodel (= 3.2.7)
- activesupport (= 3.2.7)
- activesupport (3.2.7)
+ activeresource (3.2.8)
+ activemodel (= 3.2.8)
+ activesupport (= 3.2.8)
+ activesupport (3.2.8)
i18n (~> 0.6)
multi_json (~> 1.0)
arel (3.0.2)
@@ -61,17 +61,17 @@ GEM
rack
rack-test (0.6.1)
rack (>= 1.0)
- rails (3.2.7)
- actionmailer (= 3.2.7)
- actionpack (= 3.2.7)
- activerecord (= 3.2.7)
- activeresource (= 3.2.7)
- activesupport (= 3.2.7)
+ rails (3.2.8)
+ actionmailer (= 3.2.8)
+ actionpack (= 3.2.8)
+ activerecord (= 3.2.8)
+ activeresource (= 3.2.8)
+ activesupport (= 3.2.8)
bundler (~> 1.0)
- railties (= 3.2.7)
- railties (3.2.7)
- actionpack (= 3.2.7)
- activesupport (= 3.2.7)
+ railties (= 3.2.8)
+ railties (3.2.8)
+ actionpack (= 3.2.8)
+ activesupport (= 3.2.8)
rack-ssl (~> 1.3.2)
rake (>= 0.8.7)
rdoc (~> 3.4)
View
2  lib/recommendable/acts_as_recommendable.rb
@@ -44,7 +44,7 @@ def self.top count = 1
items = self.find ids
return items.first if count == 1
- return items.sort { |x, y| ids.index(x.id) <=> ids.index(y.id) }
+ return items.sort_by { |item| ids.index(item.id) }
end
private
View
4 lib/recommendable/acts_as_recommended_to.rb
@@ -414,9 +414,7 @@ def similar_raters options = {}
raters = Recommendable.user_class.find rater_ids
# The query loses the ordering, so...
- return raters.sort do |x, y|
- rater_ids.index(x.id) <=> rater_ids.index(y.id)
- end
+ return raters.sort_by { |rater| rater_ids.index(rater.id) }
end
def liked_in_common_with rater, options = {}
Please sign in to comment.
Something went wrong with that request. Please try again.