Skip to content

Remove hoists only used once - #33

Merged
akx merged 3 commits into
akx:faster-geometry-1from
radarhere:faster-geometry-1
Sep 17, 2026
Merged

akx merged 3 commits into
akx:faster-geometry-1from
radarhere:faster-geometry-1

Conversation

@radarhere

Copy link
Copy Markdown

Two suggestions for python-pillow#9788

  1. My version of Apply hoist optimizations to Geometry.c's transforms python-pillow/Pillow#9788 (comment)
  2. XCLIP and YCLIP don't need im passed to them directly.

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 8.33333% with 22 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (faster-geometry-1@4ae228a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/libImaging/Geometry.c 8.33% 19 Missing and 3 partials ⚠️
Additional details and impacted files
@@                 Coverage Diff                  @@
##             faster-geometry-1      #33   +/-   ##
====================================================
  Coverage                     ?   65.80%           
====================================================
  Files                        ?      348           
  Lines                        ?    54839           
  Branches                     ?     3837           
====================================================
  Hits                         ?    36085           
  Misses                       ?    18358           
  Partials                     ?      396           
Flag Coverage Δ
GHA_Docker 65.80% <8.33%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@akx akx left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Minor comments, but I'm otherwise OK with this if it keeps the upstream PR moving.

Comment thread src/libImaging/Geometry.c Outdated
memset(out + x0, 0, (x1 - x0) * sizeof(pixel)); \
} \
if (yi >= 0 && yi < in_ysize) { \
if (yi >= 0 && yi < imIn->ysize) { \

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This is in a loop body?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've pushed an update.

Comment thread src/libImaging/Geometry.c Outdated
for (x = x0; x < x1; x++) {
xin = COORD(xo);
if (xin >= 0 && xin < (int)in_xsize) {
if (xin >= 0 && xin < (int)imIn->xsize) {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

This is in a loop body?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've pushed an update.

Comment thread src/libImaging/Geometry.c Outdated

#define XCLIP(im, x) (((x) < 0) ? 0 : ((x) < xsize) ? (x) : xsize - 1)
#define YCLIP(im, y) (((y) < 0) ? 0 : ((y) < ysize) ? (y) : ysize - 1)
#define XCLIP(x) (((x) < 0) ? 0 : ((x) < im->xsize) ? (x) : im->xsize - 1)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think this would be good to have use an implicit ambient xsize too. It is being called multiple times in succession in e.g. BILINEAR_BODY/BICUBIC_BODY/..., so having xsize loaded into a local will pretty certainly help the compiler.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I've pushed an update.

@akx akx left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks, let's do this :)

@akx
akx merged commit 261b5f4 into akx:faster-geometry-1 Sep 17, 2026
45 of 49 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants