-
-
Notifications
You must be signed in to change notification settings - Fork 852
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
Improve CQ10 #783
Improve CQ10 #783
Conversation
Ready for review. |
this.InputValues = inputValues; | ||
this.ClutValues = clutValues; | ||
this.OutputValues = outputValues; | ||
this.InputValues = inputValues ?? throw new ArgumentNullException(nameof(inputValues)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really prefer using Guard instead of the null-coalescing operator.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They look nicer, but are they worth the expense of an extra call and a convoluted stack that shows that the exception occurred within the Guard method instead of the actual callsite? I would advocate that we eventually replace all Guard methods with methods that throw inline so the user knows exactly where the problem is.
return hashCode; | ||
} | ||
return HashHelpers.Combine( | ||
(int)this.CurveType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CurveType.GetHashCode()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
return HashHelpers.Combine( | ||
base.GetHashCode(), | ||
(int)this.ColorantType, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.ColorantType.GetHashCode()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
hashCode = (hashCode * 397) ^ (this.InputValues?.GetHashCode() ?? 0); | ||
hashCode = (hashCode * 397) ^ (this.ClutValues?.GetHashCode() ?? 0); | ||
hashCode = (hashCode * 397) ^ (this.OutputValues?.GetHashCode() ?? 0); | ||
hashCode = (hashCode * 397) ^ this.InputValues.GetHashCode(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are we not using HashHelpers.Combine
here?
} | ||
return HashHelpers.Combine( | ||
base.GetHashCode(), | ||
this.InputChannelCount, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.InputChannelCount.GetHashCode()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Was on the fence whether or not to update all of these to use an integer or call GetHashCode and left as is for the PR.
base.GetHashCode(), | ||
this.IlluminantXyz.GetHashCode(), | ||
this.SurroundXyz.GetHashCode(), | ||
(int)this.Illuminant); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.Illuminant.GetHashCode()
?
This is happening in other places also, now starting to wonder if you should not use GetHashCode for an int?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Going to update these all to using GetHashCode() for consistency with the rest of the codebase.
Codecov Report
@@ Coverage Diff @@
## master #783 +/- ##
========================================
Coverage ? 88.7%
========================================
Files ? 1012
Lines ? 43248
Branches ? 3127
========================================
Hits ? 38363
Misses ? 4181
Partials ? 704
Continue to review full report at Codecov.
|
@dlemstra Thanks for the feedback. Addressed the PR with one comment. Let me know your thoughts on throws. I've been letting them slowly creep in in my prior PR's -- we should make a call. |
@JimBobSquarePants PING. |
@iamcarbon Just landed back in Oz. Will review properly when over my jet lag. Two things I’d like to see/discuss though.
|
@JimBobSquarePants I submitted a PR in core to polyfill HashCode. Stacktraces coming soon. |
Legend! |
Here are examples of the stack traces. For trivial argument validation on public methods, I believe we should prefer inline throws to improve the stack traces (brevity + clarity). This also eliminates code generation for the generic function and a call. THROWING USING GUARD HELPER
THROWING DIRECTLY
|
Updated to use HashCode.Combine |
src/ImageSharp/MetaData/Profiles/ICC/TagDataEntries/IccLutBToATagDataEntry.cs
Outdated
Show resolved
Hide resolved
@@ -18,19 +18,13 @@ | |||
<ProjectReference Include="..\..\src\ImageSharp\ImageSharp.csproj" /> | |||
</ItemGroup> | |||
<ItemGroup> | |||
<PackageReference Include="BitMiracle.LibJpeg.NET" Version="1.4.280" /> | |||
<PackageReference Include="Magick.NET-Q16-AnyCPU" Version="7.9.0.1" /> | |||
<PackageReference Include="xunit" Version="2.3.1" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you able to shed any light into what issues are blocking us upgrading xunit?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I spent 30 minutes on this before. I'll take another stab in CQ11.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good man! 👍
@JimBobSquarePants -- what other rad .NETCORE stuff can we polyfill. :) |
Pulling this in now. Thanks again!! |
Improve CQ10
Prerequisites
Description
Use new HashHelper overloadsUse new HashCode.Combine polyfill