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:
Kamron Batman 2026-07-25 11:17:33 -07:00
parent 0f64d834b4
commit 9df169946c
No known key found for this signature in database
GPG key ID: 7D81DF26D9A5D94A
7 changed files with 48 additions and 29 deletions

View file

@ -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)