Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The same would be true for the initial map:

Replacing

  encountered := map[uint64]bool{}
with

  encountered := make(map[uint64]bool, len(elements))
Should be faster.

Golang Hashmaps initially have one bucket with a size of 8. If more elements are added new buckets are created.

So giving a hint to initialize a correct number of things should always be faster.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: