Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
C
cocoapods
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gengmeiios
cocoapods
Commits
7eb17735
Commit
7eb17735
authored
Jan 18, 2018
by
Samuel Giddins
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[PathList] Avoid intermediary array allocations
parent
3e27274c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
17 deletions
+20
-17
path_list.rb
lib/cocoapods/sandbox/path_list.rb
+14
-13
path_list_spec.rb
spec/unit/sandbox/path_list_spec.rb
+6
-4
No files found.
lib/cocoapods/sandbox/path_list.rb
View file @
7eb17735
require
'active_support/multibyte/unicode'
require
'active_support/multibyte/unicode'
require
'find'
module
Pod
module
Pod
class
Sandbox
class
Sandbox
...
@@ -50,23 +51,23 @@ module Pod
...
@@ -50,23 +51,23 @@ module Pod
unless
root
.
exist?
unless
root
.
exist?
raise
Informative
,
"Attempt to read non existent folder `
#{
root
}
`."
raise
Informative
,
"Attempt to read non existent folder `
#{
root
}
`."
end
end
escaped_root
=
escape_path_for_glob
(
root
)
absolute_paths
=
Pathname
.
glob
(
escaped_root
+
'**/*'
,
File
::
FNM_DOTMATCH
).
lazy
dirs_and_files
=
absolute_paths
.
reject
{
|
path
|
path
.
basename
.
to_s
=~
/^\.\.?$/
}
dirs
,
files
=
dirs_and_files
.
partition
{
|
path
|
File
.
directory?
(
path
)
}
dirs
=
[]
files
=
[]
root_length
=
root
.
cleanpath
.
to_s
.
length
+
File
::
SEPARATOR
.
length
root_length
=
root
.
cleanpath
.
to_s
.
length
+
File
::
SEPARATOR
.
length
sorted_relative_paths_from_full_paths
=
lambda
do
|
paths
|
Find
.
find
(
root
)
do
|
f
|
relative_paths
=
paths
.
lazy
.
map
do
|
path
|
directory
=
File
.
directory?
(
f
)
path_string
=
path
.
to_s
f
=
f
.
slice
(
root_length
,
f
.
length
-
root_length
)
path_string
.
slice
(
root_length
,
path_string
.
length
-
root_length
)
next
if
f
.
nil?
end
relative_paths
.
sort_by
(
&
:upcase
)
(
directory
?
dirs
:
files
)
<<
f
end
end
@dirs
=
sorted_relative_paths_from_full_paths
.
call
(
dirs
)
dirs
.
sort_by!
(
&
:upcase
)
@files
=
sorted_relative_paths_from_full_paths
.
call
(
files
)
files
.
sort_by!
(
&
:upcase
)
@dirs
=
dirs
@files
=
files
@glob_cache
=
{}
@glob_cache
=
{}
end
end
...
...
spec/unit/sandbox/path_list_spec.rb
View file @
7eb17735
...
@@ -175,10 +175,12 @@ module Pod
...
@@ -175,10 +175,12 @@ module Pod
it
'orders paths case insensitively'
do
it
'orders paths case insensitively'
do
root
=
fixture
(
'banana-unordered'
)
root
=
fixture
(
'banana-unordered'
)
# Let Pathname.glob result be ordered case-sensitively
# Let Find.find result be ordered case-sensitively
Pathname
.
stubs
(
:glob
).
returns
([
Pathname
.
new
(
"
#{
root
}
/Classes/NSFetchRequest+Banana.h"
),
Find
.
stubs
(
:find
).
multiple_yields
(
Pathname
.
new
(
"
#{
root
}
/Classes/NSFetchedResultsController+Banana.h"
)])
"
#{
root
}
/Classes"
,
File
.
stubs
(
:directory?
).
returns
(
false
)
"
#{
root
}
/Classes/NSFetchRequest+Banana.h"
,
"
#{
root
}
/Classes/NSFetchedResultsController+Banana.h"
,
)
path_list
=
Sandbox
::
PathList
.
new
(
root
)
path_list
=
Sandbox
::
PathList
.
new
(
root
)
path_list
.
files
.
should
==
%w(Classes/NSFetchedResultsController+Banana.h Classes/NSFetchRequest+Banana.h)
path_list
.
files
.
should
==
%w(Classes/NSFetchedResultsController+Banana.h Classes/NSFetchRequest+Banana.h)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment