Project

General

Profile

« Previous | Next » 

Revision 36bf13fd

Added by NOYB NOYB over 9 years ago

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.

View differences:

src/usr/local/www/firewall_rules.php
488 488
$nrules = 0;
489 489
$separators = $config['filter']['separator'][strtolower($if)];
490 490

  
491
// There can be a separator before any rules are listed
492
display_separator($separators, $nrules, $columns_in_table);
491
// Get a list of separator rows and use it to call the display separator function only for rows which there are separator(s).
492
// More efficient than looping through the list of separators on every row.
493
$seprows = separator_rows($separators);
493 494

  
494 495
for ($i = 0; isset($a_filter[$i]); $i++):
495 496
	$filterent = $a_filter[$i];
496 497

  
497 498
	if (($filterent['interface'] == $if && !isset($filterent['floating'])) || (isset($filterent['floating']) && "FloatingRules" == $if)) {
499

  
500
		// Display separator(s) for section beginning at rule n
501
		if ($seprows[$nrules]) {
502
			display_separator($separators, $nrules, $columns_in_table);
503
		}
498 504
?>
499 505
					<tr id="fr<?=$nrules;?>" onClick="fr_toggle(<?=$nrules;?>)" ondblclick="document.location='firewall_rules_edit.php?id=<?=$i;?>';" <?=(isset($filterent['disabled']) ? ' class="disabled"' : '')?>>
500 506
						<td>
......
800 806
					</tr>
801 807
<?php
802 808
		$nrules++;
803
		// There can be a separator before the next rule listed, or after the last rule listed
804
		display_separator($separators, $nrules, $columns_in_table);
805 809
	}
806 810
endfor;
811

  
812
// There can be separator(s) after the last rule listed.
813
if ($seprows[$nrules]) {
814
	display_separator($separators, $nrules, $columns_in_table);
815
}
807 816
?>
808 817
				</tbody>
809 818
			</table>

Also available in: Unified diff