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

nil pointer is also considered an empty map. #2

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

Conversation

fingon
Copy link
Contributor

@fingon fingon commented Jan 4, 2018

I found it awkward to have to do New*Map before actually using them. With these pretty small changes you can just e.g. var m FooBarMap and play with it directly.

Similar changes to vectors/sets would be nice too, but I did not need them and due to performance reasons I think I am refactoring my design away from this; golang gc is stupidly expensive so these datastructures wind up being much slower than I thought. Live and learn :-)

Copy link
Owner

@tobgu tobgu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

  • A question on Store.
  • Would you mind adding some basic tests?

return zeroValue, false
}

// Store returns a new {{.MapTypeName}} containing value identified by key.
func (m *{{.MapTypeName}}) Store(key {{.MapKeyTypeName}}, value {{.MapValueTypeName}}) *{{.MapTypeName}} {
if m == nil {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A regular Go map would panic in this case. Do you think it makes sense to implicitly create a new map here?

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.

None yet

2 participants