Skip to content

Commit 7245b46

Browse files
committed
Avoid unnecessary copies of AVIF primary_item and alpha_item
When they're already contiguously present in an mdat buffer (even the same one), AvifContext::primary_item() and ::alpha_item() can return slices rather than having to copy the (potentially large) buffers. This results in a measured performance increase of ~50% for parsing a 4.7 MB AVIF (the largest in our test set): $ git checkout master $ cargo bench -- --save-baseline base avif_largest time: [2.0990 ms 2.1352 ms 2.1727 ms] $ git checkout avif-nocopy $ cargo bench -- --save-baseline avif-nocopy $ cargo bench -- --load-baseline avif-nocopy --baseline base avif_largest time: [1.0077 ms 1.0257 ms 1.0449 ms] change: [-52.649% -51.371% -50.022%] (p = 0.00 < 0.05) Performance has improved. Also, clean up some related code add add tests.
1 parent d050c64 commit 7245b46

File tree

4 files changed

+298
-124
lines changed

4 files changed

+298
-124
lines changed

0 commit comments

Comments
 (0)