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

refactor: introduce a union type for opcode_specific_columns #310

Merged
merged 5 commits into from
Mar 6, 2024

Conversation

dlubarov
Copy link
Collaborator

This may be a bit questionable since union access is unsafe, leading to additional unsafe code. I would argue that that the usual safety concern with union simply doesn't apply here, since all interpretations of the underlying data are simultaneously valid. Still, any use of unsafe is not ideal.

The use of unions also requires T: Copy, but I think that should be fine.

On the plus side, size_of_opcode_specific_columns() can now be replaced with a simple size_of() call, and code that interacts with opcode-specific columns becomes a bit cleaner.

Given the pros and cons, this is a tentative suggestion; if you prefer the old style I think that's perfectly reasonable also.

@dlubarov dlubarov force-pushed the union_for_opcode_specific_cols branch from 8692909 to a251df3 Compare February 26, 2024 07:34
@dlubarov dlubarov changed the title Introduce a union type for opcode_specific_columns refactor: introduce a union type for opcode_specific_columns Feb 26, 2024
@dlubarov dlubarov force-pushed the union_for_opcode_specific_cols branch from a251df3 to 9e65fd8 Compare February 26, 2024 07:36
This may be a bit questionable since union access is unsafe, leading to additional unsafe code. I would argue that that the usual safety concern with union simply doesn't apply here, since all interpretations of the underlying data are simultaneously valid. Still, any use of `unsafe` is not ideal.

The use of unions also requires `T: Copy`, but I think that should be fine.

On the plus side, `size_of_opcode_specific_columns()` can now be replaced with a simple `size_of()` call, and code that interacts with opcode-specific columns becomes a bit cleaner.

Given the pros and cons, this is a tentative suggestion; if you prefer the old style I think that's perfectly reasonable also.
@dlubarov dlubarov force-pushed the union_for_opcode_specific_cols branch from 9e65fd8 to fe78a9e Compare February 28, 2024 00:16
@jtguibas
Copy link
Contributor

jtguibas commented Mar 6, 2024

Thanks for the PR @dlubarov! Taking a look now, sorry we missed this.

@jtguibas jtguibas merged commit f6b9c11 into main Mar 6, 2024
5 checks passed
@jtguibas jtguibas deleted the union_for_opcode_specific_cols branch March 6, 2024 21:23
jtguibas pushed a commit that referenced this pull request Mar 29, 2024
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