Change MaskPattern.Patterns to a list #531
Merged
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.
This code changes
MaskPattern.Patterns
to a list instead of a dictionary to hopefully make some code easier to understand.Existing code
The index is stored zero-based within the QR code, and I was confused by this code here:
QRCoder/QRCoder/QRCodeGenerator.ModulePlacer.cs
Line 130 in 14a83f2
followed by
QRCoder/QRCoder/QRCodeGenerator.ModulePlacer.cs
Line 163 in 14a83f2
and
QRCoder/QRCoder/QRCodeGenerator.ModulePlacer.cs
Lines 175 to 176 in 14a83f2
which is actually correct because of
QRCoder/QRCoder/QRCodeGenerator.ModulePlacer.cs
Line 185 in 14a83f2
So since the dictionary is unnecessary, I converted it to a list. It should be faster too but I didn't check.
New code
Now we start with this:
QRCoder/QRCoder/QRCodeGenerator.ModulePlacer.cs
Lines 118 to 120 in d48a2fb
and uses are simple:
QRCoder/QRCoder/QRCodeGenerator.ModulePlacer.cs
Line 132 in d48a2fb
QRCoder/QRCoder/QRCodeGenerator.ModulePlacer.cs
Line 165 in d48a2fb
QRCoder/QRCoder/QRCodeGenerator.ModulePlacer.cs
Line 187 in d48a2fb