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
804badac
Commit
804badac
authored
Sep 27, 2019
by
allison.browne
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve peformance of utils InlineHash
Use the less expensive .to_a when a prefix is not passed.
parent
e8e5f49f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
lib/gitlab/utils/inline_hash.rb
lib/gitlab/utils/inline_hash.rb
+6
-1
spec/lib/gitlab/utils/safe_inline_hash_spec.rb
spec/lib/gitlab/utils/safe_inline_hash_spec.rb
+1
-1
No files found.
lib/gitlab/utils/inline_hash.rb
View file @
804badac
...
...
@@ -35,7 +35,12 @@ module Gitlab
def
merge_keys
(
hash
,
prefix:
nil
,
connector:
'.'
)
result
=
{}
base_prefix
=
prefix
?
"
#{
prefix
}#{
connector
}
"
:
''
pairs
=
hash
.
map
{
|
key
,
value
|
[
"
#{
base_prefix
}#{
key
}
"
,
value
]
}
pairs
=
if
prefix
hash
.
map
{
|
key
,
value
|
[
"
#{
base_prefix
}#{
key
}
"
,
value
]
}
else
hash
.
to_a
end
until
pairs
.
empty?
key
,
value
=
pairs
.
shift
...
...
spec/lib/gitlab/utils/safe_inline_hash_spec.rb
View file @
804badac
...
...
@@ -3,7 +3,7 @@
require
'fast_spec_helper'
describe
Gitlab
::
Utils
::
SafeInlineHash
do
context
'.merge_keys!'
do
describe
'.merge_keys!'
do
let
(
:source
)
{
{
'foo'
=>
{
'bar'
=>
'baz'
}
}
}
let
(
:validator
)
{
instance_double
(
Gitlab
::
Utils
::
DeepSize
,
valid?:
valid
)
}
...
...
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