style: use indexed for over arrays/lists and [] initializers
Applies the house conventions consistently across this PR's own code rather than leaving them half-applied: BanChannel had Register/Stop converted while Start kept a foreach, and ConnectionFilters was foreach throughout. Converted every foreach over an array or List, and while doing so hoisted the _reporters/_filters static field reads into a local so the loops match the snapshot pattern Report/Retract/ShouldDeny already use. Left as foreach where there is no indexer: the Dictionary walks in Firewall.ExpireEntries, PromotedGuard.Sweep and BuildAlerts, and BuildAlerts' IEnumerable parameter. Dictionary field initializers become [] (it compiles, same lowering). The three remaining new List<T>(capacity) calls keep their form -- a collection expression cannot carry the capacity hint, and all three size the list exactly. Scoped to files this PR authored or moved; pre-existing loops in AdminGump, Main and Utility are left alone. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0f64d834b4
commit
9df169946c
7 changed files with 48 additions and 29 deletions
|
|
@ -152,8 +152,9 @@ public static class IPAddressUtility
|
|||
v = 0;
|
||||
uint acc = 0;
|
||||
int octet = 0, digits = 0, dots = 0;
|
||||
foreach (var c in s)
|
||||
for (var i = 0; i < s.Length; i++)
|
||||
{
|
||||
var c = s[i];
|
||||
if (c == '.')
|
||||
{
|
||||
if (digits == 0 || octet > 255)
|
||||
|
|
@ -199,8 +200,9 @@ public static class IPAddressUtility
|
|||
v = 0;
|
||||
uint acc = 0;
|
||||
int octet = 0, digits = 0, dots = 0;
|
||||
foreach (var c in s)
|
||||
for (var i = 0; i < s.Length; i++)
|
||||
{
|
||||
var c = s[i];
|
||||
if (c == (byte)'.')
|
||||
{
|
||||
if (digits == 0 || octet > 255)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue