summaryrefslogtreecommitdiffstats
path: root/etc/inc/xmlparse.inc
diff options
context:
space:
mode:
authorErmal Luçi <eri@pfsense.org>2009-08-13 15:59:45 +0000
committerErmal Luçi <eri@pfsense.org>2009-08-13 15:59:45 +0000
commitd1bd66b422f1f4cf74b7389e051b67a40237b9fe (patch)
treea2b2012c3b60d87b2ae191ffa0ae23f4534bb2ea /etc/inc/xmlparse.inc
parent4619735332e65bd3dd4fa1d0a72ed4dd71c76a9e (diff)
downloadpfsense-d1bd66b422f1f4cf74b7389e051b67a40237b9fe.zip
pfsense-d1bd66b422f1f4cf74b7389e051b67a40237b9fe.tar.gz
Micro speedup improvements on the parser.
Diffstat (limited to 'etc/inc/xmlparse.inc')
-rw-r--r--etc/inc/xmlparse.inc20
1 files changed, 9 insertions, 11 deletions
diff --git a/etc/inc/xmlparse.inc b/etc/inc/xmlparse.inc
index 4522145..eacd528 100644
--- a/etc/inc/xmlparse.inc
+++ b/etc/inc/xmlparse.inc
@@ -49,14 +49,14 @@ function listtags() {
"serversdisabled earlyshellcmd shellcmd staticmap subqueue timerange ".
"tunnel user vip virtual_server vlan winsserver wolentry widget "
);
- return $ret;
+ return array_flip($ret);
}
/* Package XML tags that should be treat as a list not as a traditional array */
function listtags_pkg() {
$ret = array("depends_on_package", "onetoone", "queue", "rule", "servernat", "alias", "additional_files_needed", "tab", "template", "menu", "rowhelperfield", "service", "step", "package", "columnitem", "option", "item", "field", "package", "file");
- return $ret;
+ return array_flip($ret);
}
function add_elements(&$cfgarray, &$parser) {
@@ -73,8 +73,8 @@ function add_elements(&$cfgarray, &$parser) {
if ($parser->isEmptyElement) {
$cfgarray[$parser->name] = "";
} else {
- if (in_array($parser->name, $listtags))
- add_elements($cfgarray[$parser->name][count($cfgarray[$parser->name])], $parser);
+ if (isset($listtags[$parser->name]))
+ add_elements($cfgarray[$parser->name][], $parser);
else
add_elements($cfgarray[$parser->name], $parser);
}
@@ -97,7 +97,7 @@ function parse_xml_config($cffile, $rootobj, $isstring = "false") {
$listtags = listtags();
if (isset($GLOBALS['custom_listtags'])) {
foreach($GLOBALS['custom_listtags'] as $tag) {
- $listtags[] = $tag;
+ $listtags[$tag] = $tag;
}
}
return parse_xml_config_raw($cffile, $rootobj);
@@ -108,7 +108,7 @@ function parse_xml_config_pkg($cffile, $rootobj, $isstring = "false") {
$listtags = listtags_pkg();
if (isset($GLOBALS['custom_listtags_pkg'])) {
foreach($GLOBALS['custom_listtags_pkg'] as $tag) {
- $listtags[] = $tag;
+ $listtags[$tag] = $tag;
}
}
return parse_xml_config_raw($cffile, $rootobj, $isstring);
@@ -116,8 +116,6 @@ function parse_xml_config_pkg($cffile, $rootobj, $isstring = "false") {
function parse_xml_config_raw($cffile, $rootobj, $isstring = "false") {
- global $listtags;
-
$parsedcfg = array();
$par = new XMLReader();
@@ -139,7 +137,7 @@ function dump_xml_config_sub($arr, $indent) {
foreach ($arr as $ent => $val) {
if (is_array($val)) {
/* is it just a list of multiple values? */
- if (in_array(strtolower($ent), $listtags)) {
+ if (isset($listtags[strtolower($ent)])) {
foreach ($val as $cval) {
if (is_array($cval)) {
$xmlconfig .= str_repeat("\t", $indent);
@@ -184,7 +182,7 @@ function dump_xml_config($arr, $rootobj) {
$listtags = listtags();
if (isset($GLOBALS['custom_listtags'])) {
foreach($GLOBALS['custom_listtags'] as $tag) {
- $listtags[] = $tag;
+ $listtags[$tag] = $tag;
}
}
return dump_xml_config_raw($arr, $rootobj);
@@ -195,7 +193,7 @@ function dump_xml_config_pkg($arr, $rootobj) {
$listtags = listtags_pkg();
if (isset($GLOBALS['custom_listtags_pkg'])) {
foreach($GLOBALS['custom_listtags_pkg'] as $tag) {
- $listtags[] = $tag;
+ $listtags[$tag] = $tag;
}
}
return dump_xml_config_raw($arr, $rootobj);
OpenPOWER on IntegriCloud