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

gen: use voidptr key methods: map_get_1, map_set_1, map_get_and_set_1 #7390

Merged
merged 6 commits into from
Dec 18, 2020

Conversation

ntrel
Copy link
Contributor

@ntrel ntrel commented Dec 18, 2020

Part of #6991.

Use 3 of the voidptr key map methods added in #7377 in cgen and gen/json.v.
Add a test for map equality.

Use a pointer receiver for map methods get_1 and exists_1 for efficiency.

This change breaks a case in a test where indexing a map rvalue (e.g. result of a function producing a map) did work, but in several other cases this did not work anyway. I tried to keep support for that case but it seems too awkward to do in this pull.
Update: I've fixed that case.

Also add a cgen macro ADDR to take the address of an rvalue. This helps keep code readable and makes it easy to support rvalue references without having to remember the C99 trick.

@ntrel ntrel force-pushed the map-voidptr branch 2 times, most recently from 96d4976 to 42f805b Compare December 18, 2020 15:58
Also add a cgen macro ADDR.
@ntrel ntrel marked this pull request as ready for review December 18, 2020 16:20
@spytheman spytheman merged commit 042449c into vlang:master Dec 18, 2020
@ntrel ntrel deleted the map-voidptr branch December 20, 2020 12:25
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