Repository navigation
Optimize AlignmentPatterns #699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
a61ad31
Optimize AlignmentPatterns
KrisVandermotten de2309f
Use INDEX_OFFSET constant
KrisVandermotten d033cf4
Add comment about implementing IEquatable<Point>
KrisVandermotten 1a9d458
Merge branch 'master' into AlignmentPatterns
Shane32 c75997a
merged from master
KrisVandermotten File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,56 +1,31 @@ | ||
| using System.Reflection; | ||
|
|
||
| namespace QRCoder; | ||
|
|
||
| public partial class QRCodeGenerator | ||
| { | ||
| /// <summary> | ||
| /// Represents a 2D point with integer coordinates. | ||
| /// Represents a 2D point with byte coordinates. | ||
| /// </summary> | ||
| private readonly struct Point : IEquatable<Point> | ||
| private readonly struct Point | ||
| { | ||
| /// <summary> | ||
| /// Gets the X-coordinate of the point. | ||
| /// </summary> | ||
| public int X { get; } | ||
| public byte X { get; } | ||
|
|
||
| /// <summary> | ||
| /// Gets the Y-coordinate of the point. | ||
| /// </summary> | ||
| public int Y { get; } | ||
| public byte Y { get; } | ||
|
|
||
| /// <summary> | ||
| /// Initializes a new instance of the <see cref="Point"/> struct with specified X and Y coordinates. | ||
| /// </summary> | ||
| /// <param name="x">The X-coordinate of the point.</param> | ||
| /// <param name="y">The Y-coordinate of the point.</param> | ||
| public Point(int x, int y) | ||
| public Point(byte x, byte y) | ||
| { | ||
| X = x; | ||
| Y = y; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Determines whether the specified <see cref="Point"/> is equal to the current <see cref="Point"/>. | ||
| /// </summary> | ||
| /// <param name="other">The <see cref="Point"/> to compare with the current <see cref="Point"/>.</param> | ||
| /// <returns>True if the specified <see cref="Point"/> has the same X and Y coordinates as the current <see cref="Point"/>; otherwise, false.</returns> | ||
| /// <remarks> | ||
| /// If this method which implements <see cref="IEquatable{T}.Equals(T)"/> is not implemented, comparisons used by methods such as <see cref="List{T}.Contains(T)"/> | ||
| /// fall back to reflection, which causes heap allocations internally during the calls to <see cref="FieldInfo.GetValue(object)"/>. | ||
| /// </remarks> | ||
| public bool Equals(Point other) | ||
| => X == other.X && Y == other.Y; | ||
|
|
||
| /// <inheritdoc/> | ||
| public override bool Equals(object? obj) => obj is Point point && Equals(point); | ||
|
|
||
| /// <inheritdoc/> | ||
| public override int GetHashCode() | ||
| #if NET5_0_OR_GREATER | ||
| => HashCode.Combine(X, Y); | ||
| #else | ||
| => X ^ (int)(((uint)Y << 16) | ((uint)Y >> 16)); | ||
| #endif | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.