Skip to content

some improvements to distance, apply and fill methods in Raster* #1823

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 6 commits into from Jul 5, 2016
Merged

some improvements to distance, apply and fill methods in Raster* #1823

merged 6 commits into from Jul 5, 2016

Conversation

ghost
Copy link

@ghost ghost commented Jul 4, 2016

mostly reducing count of function calls (property reads)
@marcusnaslund

@ghost ghost added the peer review label Jul 4, 2016
@@ -106,7 +115,7 @@ RasterMonochrome: class extends RasterPacked {
result += distance sqrt()
}
}
result /= (this size x squared + this size y squared as Float sqrt())
result /= (sizeX squared + sizeY squared as Float sqrt())
Copy link
Author

@ghost ghost Jul 4, 2016

Choose a reason for hiding this comment

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

I'm pretty sure this is a bug (should be more like (x^2 + y^2) sqrt()) but fixing it fails the RasterMonochrome lossy ascii serialization test case.

Copy link
Contributor

@marcusnaslund marcusnaslund Jul 4, 2016

Choose a reason for hiding this comment

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

Oh definitely.

Copy link
Contributor

@marcusnaslund marcusnaslund Jul 5, 2016

Choose a reason for hiding this comment

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

I made an issue: #1824

@@ -172,9 +174,9 @@ RasterYuv420Semiplanar: class extends RasterImage {
vSource += 2
}
}
yRow += this y stride
yRow += yStride
if (y % 2 == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You can remove these braces while you're at it

Copy link
Author

Choose a reason for hiding this comment

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

Updated.

@marcusnaslund
Copy link
Contributor

Neat. I will just ask for two things:

  1. Benchmark this and see how much better the changes are.

  2. You have many new helper variables which have the same name as the class member (stride := this stride etc.). These should be renamed (thisStride := this stride, as you have done in some places, perhaps).

@ghost
Copy link
Author

ghost commented Jul 5, 2016

Tested by running one of the tests in other project, which depends heavily on distance. Before changes:

Total time: 10.12 s
Total time: 8.91 s

after switching to this branch:

Total time: 4.14 s
Total time: 4.37 s

I will update the variable names.

@ghost
Copy link
Author

ghost commented Jul 5, 2016

Complete test suite in the other project, before 91.80 s, after 79.98 s .

@marcusnaslund
Copy link
Contributor

Nice! :) I'm happy once the variable names have changed.

@ghost
Copy link
Author

ghost commented Jul 5, 2016

Variable names are updated, check the latest commit.

@@ -61,14 +66,15 @@ RasterUv: class extends RasterPacked {
vSource := vRow
width := this size x
height := this size y
stride := this stride
Copy link
Contributor

Choose a reason for hiding this comment

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

well well well

@marcusnaslund
Copy link
Contributor

Trying to trick me, eh? You should fear my power ⚡

@ghost
Copy link
Author

ghost commented Jul 5, 2016

sorry 😭
anything more here ?

@marcusnaslund
Copy link
Contributor

marcusnaslund commented Jul 5, 2016

No, looks good now. But as punishment, I will wait an extra minute before merging this.

@marcusnaslund marcusnaslund merged commit 38534c8 into magic-lang:develop Jul 5, 2016
@ghost ghost deleted the distimpr branch July 5, 2016 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant