From 8b069b506145942f67d040777b406ed2293c8646 Mon Sep 17 00:00:00 2001 From: Samuel Giddins Date: Tue, 19 Feb 2019 11:39:37 +0100 Subject: [PATCH] Slight path resolution performance impovements by reducing allocations --- .../project/object/helpers/groupable_helper.rb | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/lib/xcodeproj/project/object/helpers/groupable_helper.rb b/lib/xcodeproj/project/object/helpers/groupable_helper.rb index 70654ebf7..20939b799 100644 --- a/lib/xcodeproj/project/object/helpers/groupable_helper.rb +++ b/lib/xcodeproj/project/object/helpers/groupable_helper.rb @@ -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 @@ -115,11 +115,16 @@ def real_path(object) def full_path(object) folder = case object.source_tree when '' - 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 '' - Pathname.new('/') + Pathname.new('/'.freeze) else Pathname.new("${#{object.source_tree}}") end @@ -140,10 +145,11 @@ def full_path(object) def source_tree_real_path(object) case object.source_tree when '' - 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