Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
admin-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Pleroma
admin-fe
Commits
88c28f5d
Commit
88c28f5d
authored
7 years ago
by
Yuga Sun
Committed by
花裤衩
7 years ago
Browse files
Options
Downloads
Patches
Plain Diff
perf: change in operation to Object.keys (#518)
parent
26b84847
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/utils/index.js
+13
-17
13 additions, 17 deletions
src/utils/index.js
with
13 additions
and
17 deletions
src/utils/index.js
+
13
−
17
View file @
88c28f5d
...
...
@@ -131,16 +131,14 @@ export function objectMerge(target, source) {
if
(
Array
.
isArray
(
source
))
{
return
source
.
slice
()
}
for
(
const
property
in
source
)
{
if
(
source
.
hasOwnProperty
(
property
))
{
const
sourceProperty
=
source
[
property
]
if
(
typeof
sourceProperty
===
'
object
'
)
{
target
[
property
]
=
objectMerge
(
target
[
property
],
sourceProperty
)
continue
}
Object
.
keys
(
source
).
forEach
((
property
)
=>
{
const
sourceProperty
=
source
[
property
]
if
(
typeof
sourceProperty
===
'
object
'
)
{
target
[
property
]
=
objectMerge
(
target
[
property
],
sourceProperty
)
}
else
{
target
[
property
]
=
sourceProperty
}
}
}
)
return
target
}
...
...
@@ -253,15 +251,13 @@ export function deepClone(source) {
throw
new
Error
(
'
error arguments
'
,
'
shallowClone
'
)
}
const
targetObj
=
source
.
constructor
===
Array
?
[]
:
{}
for
(
const
keys
in
source
)
{
if
(
source
.
hasOwnProperty
(
keys
))
{
if
(
source
[
keys
]
&&
typeof
source
[
keys
]
===
'
object
'
)
{
targetObj
[
keys
]
=
source
[
keys
].
constructor
===
Array
?
[]
:
{}
targetObj
[
keys
]
=
deepClone
(
source
[
keys
])
}
else
{
targetObj
[
keys
]
=
source
[
keys
]
}
Object
.
keys
(
source
).
forEach
((
keys
)
=>
{
if
(
source
[
keys
]
&&
typeof
source
[
keys
]
===
'
object
'
)
{
targetObj
[
keys
]
=
source
[
keys
].
constructor
===
Array
?
[]
:
{}
targetObj
[
keys
]
=
deepClone
(
source
[
keys
])
}
else
{
targetObj
[
keys
]
=
source
[
keys
]
}
}
}
)
return
targetObj
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment