Skip to content

LibGfx/CCITT: Make decoding of wide ccitt3-2d and ccitt-4 images faster#26083

Merged
nico merged 1 commit intoSerenityOS:masterfrom
nico:ccitt-less-slow
Jul 31, 2025
Merged

LibGfx/CCITT: Make decoding of wide ccitt3-2d and ccitt-4 images faster#26083
nico merged 1 commit intoSerenityOS:masterfrom
nico:ccitt-less-slow

Conversation

@nico
Copy link
Copy Markdown
Contributor

@nico nico commented Jul 30, 2025

take_first() on a Vector is O(n), meaning this function used to have O(n^2) behavior in the width of an image.

We can just use a span instead, which can be be advanced in O(1) time.

Makes

pdf --debugging-stats ~/Downloads/ignition.pdf

go from 10.2s to 6.7s, 34% faster.

Makes the first 50 pages of

pdf --debugging-stats pdf-stuff/Mellor_ACTITC_10.pdf

go from 65.9s to 13.2s, 80% faster.

Fixes #26082.

`take_first()` on a Vector is O(n), meaning this function used to have
O(n^2) behavior in the width of an image.

We can just use a span instead, which can be be advanced in O(1) time.

Makes

    pdf --debugging-stats ~/Downloads/ignition.pdf

go from 10.2s to 6.7s, 34% faster.

Makes the first 50 pages of

    pdf --debugging-stats pdf-stuff/Mellor_ACTITC_10.pdf

go from 65.9s to 13.2s, 80% faster.

Fixes SerenityOS#26082.
@nico nico requested a review from LucasChollet July 30, 2025 23:30
@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Jul 30, 2025
Copy link
Copy Markdown
Contributor

@Hendiadyoin1 Hendiadyoin1 left a comment

Choose a reason for hiding this comment

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

Juicy speed up!

Copy link
Copy Markdown
Member

@LucasChollet LucasChollet left a comment

Choose a reason for hiding this comment

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

LGTM, and thanks for the perf improvement!

@nico nico merged commit 787c439 into SerenityOS:master Jul 31, 2025
22 of 23 checks passed
@nico nico deleted the ccitt-less-slow branch July 31, 2025 18:59
@github-actions github-actions bot removed the 👀 pr-needs-review PR needs review from a maintainer or community member label Jul 31, 2025
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.

CCITT decoder is slow for wide images

3 participants