-
-
Save cagmz/a9c3e752d14fc558e477fdd9525b700f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 50 MB + more memory | |
def contacts_for_vendor(vendor) | |
@_contacts_for_vendor ||= | |
Hash.new do |vendor_hash, v| | |
vendor_hash[v] = | |
contacts_for(v).select do |c| | |
v.ids.include?(c.login_id) | |
end | |
end | |
@_contacts_for_vendor[vendor] | |
end | |
# less memory | |
def contacts_hash | |
@_hash ||= {} | |
end | |
def contacts_for_vendor(vendor) | |
contacts_hash[vendor.id] ||= contacts_for(vendor).select do |c| | |
vendor.ids.include?(c.login_id) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment