Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OpnSense
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kulya
OpnSense
Commits
7d9ae367
Commit
7d9ae367
authored
Dec 03, 2016
by
Ad Schellevis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
(config) performance improvement array_key_exists() vs isset()
parent
5bfa41fd
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
5 deletions
+5
-5
Config.php
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
+5
-5
No files found.
src/opnsense/mvc/app/library/OPNsense/Core/Config.php
View file @
7d9ae367
...
...
@@ -102,7 +102,7 @@ class Config extends Singleton
// copy attributes to @attribute key item
foreach
(
$node
->
attributes
()
as
$AttrKey
=>
$AttrValue
)
{
if
(
!
array_key_exists
(
'@attributes'
,
$result
))
{
if
(
!
isset
(
$result
[
'@attributes'
]
))
{
$result
[
'@attributes'
]
=
array
();
}
$result
[
'@attributes'
][
$AttrKey
]
=
$AttrValue
->
__toString
();
...
...
@@ -112,7 +112,7 @@ class Config extends Singleton
$xmlNodeName
=
$xmlNode
->
getName
();
if
(
$xmlNode
->
count
()
>
0
)
{
$tmpNode
=
$this
->
toArray
(
$forceList
,
$xmlNode
);
if
(
array_key_exists
(
$xmlNodeName
,
$result
))
{
if
(
isset
(
$result
[
$xmlNodeName
]
))
{
$old_content
=
$result
[
$xmlNodeName
];
// check if array content is associative, move items to new list
// (handles first item of specific type)
...
...
@@ -121,7 +121,7 @@ class Config extends Singleton
$result
[
$xmlNodeName
][]
=
$old_content
;
}
$result
[
$xmlNodeName
][]
=
$tmpNode
;
}
elseif
(
is
_array
(
$forceList
)
&&
array_key_exists
(
$xmlNodeName
,
$forceList
))
{
}
elseif
(
is
set
(
$forceList
[
$xmlNodeName
]
))
{
// force tag in an array
$result
[
$xmlNodeName
]
=
array
();
$result
[
$xmlNodeName
][]
=
$tmpNode
;
...
...
@@ -129,7 +129,7 @@ class Config extends Singleton
$result
[
$xmlNodeName
]
=
$tmpNode
;
}
}
else
{
if
(
array_key_exists
(
$xmlNodeName
,
$result
))
{
if
(
isset
(
$result
[
$xmlNodeName
]
))
{
// repeating item
if
(
!
is_array
(
$result
[
$xmlNodeName
]))
{
// move first item into list
...
...
@@ -140,7 +140,7 @@ class Config extends Singleton
$result
[
$xmlNodeName
][]
=
$xmlNode
->
__toString
();
}
else
{
// single content item
if
(
is
_array
(
$forceList
)
&&
array_key_exists
(
$xmlNodeName
,
$forceList
))
{
if
(
is
set
(
$forceList
[
$xmlNodeName
]
))
{
$result
[
$xmlNodeName
]
=
array
();
if
(
$xmlNode
->
__toString
()
!=
null
&&
trim
(
$xmlNode
->
__toString
())
!==
""
)
{
$result
[
$xmlNodeName
][]
=
$xmlNode
->
__toString
();
...
...
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