-
-
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
Reduce code duplication due to reified generics #1444
Conversation
@@ -127,7 +127,7 @@ protected override void OnFrameApply(ImageFrame<TPixel> source) | |||
in verticalOperation); | |||
|
|||
// Compute the horizontal 1D convolutions and accumulate the partial results on the target buffer | |||
var horizontalOperation = new ApplyHorizontalConvolutionRowOperation(sourceRectangle, processingBuffer, firstPassBuffer, kernel, parameters.Z, parameters.W); | |||
var horizontalOperation = new BokehBlurProcessor.ApplyHorizontalConvolutionRowOperation(sourceRectangle, processingBuffer, firstPassBuffer, kernel, parameters.Z, parameters.W); |
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.
Can you not reference the processor passed to the constructor?
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.
Not sure what you mean - this is a static reference, we're not accessing an instance member. That's just the qualified type that's declared within BokehBlurProcess
, so we need the parent type name when using it 🤔
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 misread, sorry, carry on. 👍
@Sergio0694 Nice! Always on the lookout for things like this. We need to ensure the amount of code we produce is as small as possible to avoid issues with AOT. |
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.
LGTM 🚀
Codecov Report
@@ Coverage Diff @@
## master #1444 +/- ##
=======================================
Coverage 83.68% 83.68%
=======================================
Files 734 734
Lines 31990 31990
Branches 3605 3605
=======================================
Hits 26772 26772
Misses 4505 4505
Partials 713 713
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Reduce code duplication due to reified generics
Prerequisites
Description
The
BokehBlurProcessor<TPixel>
type had one of the internal row iterators that worked on non-generic types, but having that nested type defined within the generic processor class caused the code to be duplicated and compiled again for every single pixel type that the process was applied to. I moved that to the non-generic processor type so the same generic instantiation can be reduced. This will reduce the binary size in AOT scenarios, and reduce the load on the JIT otherwise.