From 36bf13fd637a1ad3c0d8e57cdcf3d51519ec51e1 Mon Sep 17 00:00:00 2001 From: NOYB Date: Thu, 11 Feb 2016 00:09:37 -0800 Subject: Firewall / Rules - Display Separators Efficiency Use a list of separator rows to call the display separator function only for rows which there are separator(s). More efficient than looping through the list of separators on every row. --- src/usr/local/www/firewall_nat.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/usr/local/www/firewall_nat.php') diff --git a/src/usr/local/www/firewall_nat.php b/src/usr/local/www/firewall_nat.php index 80f603e..25e95c8 100644 --- a/src/usr/local/www/firewall_nat.php +++ b/src/usr/local/www/firewall_nat.php @@ -260,11 +260,17 @@ $columns_in_table = 13; $nnats = $i = 0; $separators = $config['nat']['separator']; -// There can be a separator before any rules are listed -display_separator($separators, $nnats, $columns_in_table); +// Get a list of separator rows and use it to call the display separator function only for rows which there are separator(s). +// More efficient than looping through the list of separators on every row. +$seprows = separator_rows($separators); foreach ($a_nat as $natent): + // Display separator(s) for section beginning at rule n + if ($seprows[$nnats]) { + display_separator($separators, $nnats, $columns_in_table); + } + $alias = rule_columns_with_alias( $natent['source']['address'], pprint_port($natent['source']['port']), @@ -426,10 +432,12 @@ foreach ($a_nat as $natent): $i++; $nnats++; - // There can be a separator before the next rule listed, or after the last rule listed - display_separator($separators, $nnats, $columns_in_table); - endforeach; + +// There can be separator(s) after the last rule listed. +if ($seprows[$nnats]) { + display_separator($separators, $nnats, $columns_in_table); +} ?> -- cgit v1.1