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

Simplify reflect.lookupPrototype #278

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

Conversation

karlseguin
Copy link
Contributor

Switch from stable sort which was copied from std, to std.mem.sortUnstable. Remove block.zig. This also has the benefit of working as-is in Zig 0.14, whereas block.zig / std.mem.sort doesn't (and I can't figure out why).

lookupPrototype is now done in a single pass (post-sort). Previous, the initial pass was only really used to set proto_index which the sorter could use (and, in doing so, invalidate proto_index). But, as far as I can tell, proto_index wasn't needed to sort. All you need to know is whether proto_T is null or not and, if both A and B have a proto_T, whether a.proto_T == b.T.

Also optimized lookupPrototype to only scan structs before the current struct, as should be guaranteed by the sort.

Switch from stable sort which was copied from std, to std.mem.sortUnstable.
Remove block.zig. This also has the benefit of working as-is in Zig 0.14,
whereas block.zig / std.mem.sort doesn't (and I can't figure out why).

lookupPrototype is now done in a single pass (post-sort). Previous, the initial
pass was only really used to set proto_index which the sorter could use (and,
in doing so, invalidate proto_index). But, as far as I can tell, proto_index
wasn't needed to sort. All you need to know is whether proto_T is null or not
and, if both A and B have a proto_T, whether a.proto_T == b.T.

Also optimized lookupPrototype to only scan structs before the current struct,
as should be guaranteed by the sort.
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.

1 participant