Take benchmarks out of real_name, memoize it

This commit is contained in:
Raphael 2010-11-27 18:04:31 -05:00
parent cedf4302a7
commit e8310f2a19

View file

@ -68,16 +68,11 @@ class Person
end end
def real_name def real_name
result = nil @real_name ||= if profile.first_name.nil? || profile.first_name.empty?
time = Benchmark.realtime do self.diaspora_handle
result = if profile.first_name.nil? || profile.first_name.empty? else
self.diaspora_handle "#{profile.first_name.to_s} #{profile.last_name.to_s}"
else end
"#{profile.first_name.to_s} #{profile.last_name.to_s}"
end
end
Rails.logger.info "event=real_name ms=#{time}"
result
end end
def owns?(post) def owns?(post)