Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1cc26e0f
Commit
1cc26e0f
authored
Dec 22, 2015
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve performance of `StringPath`
parent
bd4899be
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
4 deletions
+11
-4
lib/gitlab/string_path.rb
lib/gitlab/string_path.rb
+11
-4
No files found.
lib/gitlab/string_path.rb
View file @
1cc26e0f
...
...
@@ -5,15 +5,15 @@ module Gitlab
# This is IO-operations safe class, that does similar job to
# Ruby's Pathname but without the risk of accessing filesystem.
#
# TODO: better support for '.
/' and '.
./'
# TODO: better support for '.
./' and '
./'
#
class
StringPath
attr_reader
:path
,
:universe
def
initialize
(
path
,
universe
)
@path
=
prepare
(
path
)
@universe
=
universe
.
map
{
|
entry
|
prepare
(
entry
)
}
@universe
.
unshift
(
'./'
)
unless
@universe
.
include?
(
'./'
)
@universe
=
Set
.
new
(
universe
.
map
{
|
entry
|
prepare
(
entry
)
})
@universe
.
add
(
'./'
)
end
def
to_s
...
...
@@ -64,7 +64,10 @@ module Gitlab
end
def
children
descendants
.
select
{
|
descendant
|
descendant
.
parent
==
self
}
return
[]
unless
directory?
return
@children
if
@children
children
=
@universe
.
select
{
|
entry
|
entry
=~
%r{^
#{
@path
}
[^/]+/?$}
}
@children
=
children
.
map
{
|
path
|
new
(
path
)
}
end
def
directories
...
...
@@ -85,6 +88,10 @@ module Gitlab
@path
==
other
.
path
&&
@universe
==
other
.
universe
end
def
inspect
"
#{
self
.
class
.
name
}
:
#{
@path
}
"
end
private
def
new
(
path
)
...
...
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