PERF: avoid needless :try invokes respond_to? etc

This commit is contained in:
Sam 2015-10-02 15:00:00 +10:00
parent 6246dd0aa2
commit 43345063b9
2 changed files with 4 additions and 4 deletions

View file

@ -9,15 +9,15 @@ class BasicPostSerializer < ApplicationSerializer
:cooked_hidden :cooked_hidden
def name def name
object.user.try(:name) object.user && object.user.name
end end
def username def username
object.user.try(:username) object.user && object.user.username
end end
def avatar_template def avatar_template
object.user.try(:avatar_template) object.user && object.user.avatar_template
end end
def cooked_hidden def cooked_hidden

View file

@ -74,7 +74,7 @@ class PostSerializer < BasicPostSerializer
end end
def topic_slug def topic_slug
object.try(:topic).try(:slug) object.topic && object.topic.slug
end end
def include_topic_title? def include_topic_title?