Skip to content
Open
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion MaxMind.Db/Network.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ namespace MaxMind.Db
/// <summary>
/// <c>Network</c> represents an IP network.
/// </summary>
public sealed class Network
public struct Network
{
private readonly IPAddress ip;

Expand All @@ -15,6 +15,12 @@ public sealed class Network
/// </summary>
public int PrefixLength { get; }

// Align the type on a 16 byte boundary. Ignore the compiler warning. The
// alignment improves performance on aarch64 and linux x64.
#pragma warning disable CS0169
private int _Padding;
#pragma warning restore CS0169
Comment on lines 18 to 22

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The naming of the new field _Padding does not follow the existing convention in the project for private fields, which is _camelCase (e.g., _database, _fileName in Reader.cs). It should be _padding for consistency.

Additionally, the comment can be made more concise and formal. The reference to 'linux x64' can be simplified to 'x64' as alignment benefits are typically architecture-specific, not OS-specific. The part about ignoring the compiler warning is also redundant given the #pragma directive.

// This field is intentionally unused. It pads the struct to 16 bytes
// to improve performance on aarch64 and x64.
#pragma warning disable CS0169
        private int _padding;
#pragma warning restore CS0169

Copy link
Author

@jashook jashook Feb 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will keep linux x64 as the 16 byte type is treated specially in that ABI.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will keep the comment open for context.


/// <summary>
/// The first address in the network.
/// </summary>
Expand Down
Loading