rust icon indicating copy to clipboard operation
rust copied to clipboard

Add some unsafe magic for minimal optimizations, add .idea to .gitignore and fix some typos

Open Kleinmarb opened this issue 1 year ago • 3 comments

Thanks for the amazing contribution to open source url parsing!

I am using this lib right now and thought that I should look into it a bit, I ended up doing minor changes.

I understand if the unsafe code gets rejected, but I even left some safety comments.

Kleinmarb avatar Aug 02 '24 21:08 Kleinmarb

Also can you fix clippy errors?

anonrig avatar Aug 02 '24 21:08 anonrig

I added tests and comments that illustrate which number maps to which enum variant.

Regarding the clippy errors, I don't get any.

Now let's talk about performance: If I'm honest there will be a performance difference but it will be negligible. But the code I wrote is 100% safe, you can trust me on that one since I added a#[repr(u32)] on the enum which allows for safe transmution between value as u32 and the enum as long as value is not bigger than the number of variants of the enum -1, but we check for that.

If you still think its risky, just deny the commit, it's alright for me.

Kleinmarb avatar Aug 03 '24 15:08 Kleinmarb

Oh ok I should have done the assembly check myself. Thanks for pointing out that it produces the same exact instructions.

Kleinmarb avatar Aug 03 '24 16:08 Kleinmarb