Skip to content

Commit

Permalink
Merge pull request #664 from CocoaPods/segiddins/slight-path-improvem…
Browse files Browse the repository at this point in the history
…ents

Slight path resolution performance improvements by reducing allocations
  • Loading branch information
dnkoutso authored Feb 19, 2019
2 parents 3d9967b + 8b069b5 commit 08b4695
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions lib/xcodeproj/project/object/helpers/groupable_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ def move(object, new_parent)
#
def real_path(object)
source_tree = source_tree_real_path(object)
path = object.path || ''
path = object.path || ''.freeze
if source_tree
source_tree + path
else
Expand All @@ -115,11 +115,16 @@ def real_path(object)
def full_path(object)
folder = case object.source_tree
when '<group>'
parent(object).isa != 'PBXProject' ? full_path(parent(object)) : nil
object_parent = parent(object)
if object_parent.isa == 'PBXProject'.freeze
nil
else
full_path(object_parent)
end
when 'SOURCE_ROOT'
nil
when '<absolute>'
Pathname.new('/')
Pathname.new('/'.freeze)
else
Pathname.new("${#{object.source_tree}}")
end
Expand All @@ -140,10 +145,11 @@ def full_path(object)
def source_tree_real_path(object)
case object.source_tree
when '<group>'
if parent(object).isa == 'PBXProject'
object_parent = parent(object)
if object_parent.isa == 'PBXProject'.freeze
object.project.project_dir
else
real_path(parent(object))
real_path(object_parent)
end
when 'SOURCE_ROOT'
object.project.project_dir
Expand Down

0 comments on commit 08b4695

Please sign in to comment.