Skip to content
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

struct FrameTileThreadData::lowest_pixel_mem: Make into Vec #878

Merged
merged 1 commit into from
Mar 21, 2024

Conversation

randomPoison
Copy link
Collaborator

@randomPoison randomPoison commented Mar 20, 2024

Also remove FrameTileThreadData because it only had a single field and was only used in one place. lowest_pixel_mem is now a direct field of Rav1dFrameData.

@rinon let me know if this looks like it'll conflict with your changes. From what I saw it doesn't look like you changed FrameTileThreadData so I'm not expecting it to conflict, but we can wait to merge this until after your changes are merged if that'll help.

Also remove `FrameTileThreadData` because it only had a single field and was only used in one place. `lowest_pixel_mem` is now a field of `Rav1dFrameData`.
@kkysen kkysen changed the title FrameTileThreadData::lowest_pixel_mem: Make into Vec FrameTileThreadData::lowest_pixel_mem: Make into Vec Mar 21, 2024
@kkysen kkysen changed the title FrameTileThreadData::lowest_pixel_mem: Make into Vec struct FrameTileThreadData::lowest_pixel_mem: Make into Vec Mar 21, 2024
Copy link
Collaborator

@kkysen kkysen left a comment

Choose a reason for hiding this comment

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

LGTM besides using .resize_with instead.

let mut lowest_pixel_ptr = f.tile_thread.lowest_pixel_mem;
// TODO: Fallible allocation
f.lowest_pixel_mem
.resize(lowest_pixel_mem_sz as usize, Default::default());
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
.resize(lowest_pixel_mem_sz as usize, Default::default());
.resize_with(lowest_pixel_mem_sz as usize, Default::default);

Copy link
Collaborator Author

@randomPoison randomPoison Mar 21, 2024

Choose a reason for hiding this comment

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

Why though? What's the difference between these two? The data is Copy so the end result is the same.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The docs recommend it for Default::default and it optimizes a little bit better, since .resize does a write for n - 1, cloning them, and then writes the last one without the clone. .resize_with just write all n at once, so the codegen is better, and the source is a bit cleaner.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Noted. I'll use resize_with going forward.

@randomPoison randomPoison merged commit e20db98 into main Mar 21, 2024
36 checks passed
@randomPoison randomPoison deleted the legare/lowest_pixel_mem branch March 21, 2024 20:57
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.

FrameTileThreadData: Make fields safe
2 participants