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

Add option to deduplicate impl blocks #3150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nasso
Copy link

@nasso nasso commented Feb 23, 2025

Same idea as the existing merge_extern_blocks, but for impl blocks.

This is particularly useful when dealing with large "newtype" enums:

Without --merge-impl-blocks:

impl AVCodecID {
    pub const AV_CODEC_ID_NONE: AVCodecID = AVCodecID(0);
}
impl AVCodecID {
    pub const AV_CODEC_ID_MPEG1VIDEO: AVCodecID = AVCodecID(1);
}
impl AVCodecID {
    #[doc = "< preferred ID for MPEG-1/2 video decoding"]
    pub const AV_CODEC_ID_MPEG2VIDEO: AVCodecID = AVCodecID(2);
}
impl AVCodecID {
    pub const AV_CODEC_ID_H261: AVCodecID = AVCodecID(3);
}
impl AVCodecID {
    pub const AV_CODEC_ID_H263: AVCodecID = AVCodecID(4);
}
// ...

With --merge-impl-blocks:

impl AVCodecID {
    pub const AV_CODEC_ID_NONE: AVCodecID = AVCodecID(0);
    pub const AV_CODEC_ID_MPEG1VIDEO: AVCodecID = AVCodecID(1);
    #[doc = "< preferred ID for MPEG-1/2 video decoding"]
    pub const AV_CODEC_ID_MPEG2VIDEO: AVCodecID = AVCodecID(2);
    pub const AV_CODEC_ID_H261: AVCodecID = AVCodecID(3);
    pub const AV_CODEC_ID_H263: AVCodecID = AVCodecID(4);
    pub const AV_CODEC_ID_RV10: AVCodecID = AVCodecID(5);
    pub const AV_CODEC_ID_RV20: AVCodecID = AVCodecID(6);
    pub const AV_CODEC_ID_MJPEG: AVCodecID = AVCodecID(7);
    pub const AV_CODEC_ID_MJPEGB: AVCodecID = AVCodecID(8);
    pub const AV_CODEC_ID_LJPEG: AVCodecID = AVCodecID(9);
    pub const AV_CODEC_ID_SP5X: AVCodecID = AVCodecID(10);
    pub const AV_CODEC_ID_JPEGLS: AVCodecID = AVCodecID(11);
    pub const AV_CODEC_ID_MPEG4: AVCodecID = AVCodecID(12);
    pub const AV_CODEC_ID_RAWVIDEO: AVCodecID = AVCodecID(13);
    // ...
}

@nasso nasso force-pushed the nasso/push-qnylysyyttmp branch from 1f0c2bb to 6f67f7e Compare February 23, 2025 12:11
@oberrich
Copy link

oberrich commented Feb 24, 2025

This needs to respect attributes in order to work correctly, I'm working on a larger patch for this: #3088 (comment)
Namely, merge_cfg_attr should be able to take care of this.
We need to make sure all of the passes work on top of each other and we can layer them appropriately.

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.

2 participants