A quick micro benchmark shows that we can completely eliminate allocation (and by extension GC) by splitting the IP string up into 4 ints.
[Benchmark] public UnfilteredClass TestUnfilteredClass() { UnfilteredClass unfiltered = new UnfilteredClass(); for (int i = 0; i < 10000; i++) { unfiltered = new() { Id = 1, Filtered = 1, Ip = "127.0.0.1", Port1 = 80, Port2 = 443, ResponseCode = 1 }; } return unfiltered; } [Benchmark] public UnfilteredStruct TestUnfilteredStruct() { UnfilteredStruct unfiltered = new UnfilteredStruct(); for (int i = 0; i < 10000; i++) { unfiltered = new() { Id = 1, Filtered = 1, Ip1 = 127, Ip2 = 0, Ip3 = 0, Ip4 = 1, Port1 = 80, Port2 = 443, ResponseCode = 1 }; } return unfiltered; }
No dependencies set.
The note is not visible to the blocked user.
A quick micro benchmark shows that we can completely eliminate allocation (and by extension GC) by splitting the IP string up into 4 ints.