3 ms·
> For example, on performance critical paths always use a standard for loop, never a for range one. i am curious, why would one use a normal for loop, instead
by kazen44 8y ago
> For example, on performance critical paths always use a standard for loop, never a for range one.
i am curious, why would one use a normal for loop, instead of a range one?
- pjmlp 8y agoA range one might introduce boxing depending on the types being iterated.
- GenericsMotors 8y agoOr use a language with reified generics :)
- dullgiulio 8y agoGo maps are reified generics, and very efficient ones at that.
- candiodari 8y agoWhat you mean is it's a set of C macros, except built-in to the compiler. Great if it's exactly what you need. And you're prepared for severe WTF moments (e.g. equality on map values is ... not the same as equality on variables of the same type containing the same thing). Also, expect the whole thing to be useless if you need slight complexity (e.g. you can use strings as keys, but not bytes (either Bytes, or []byte, but you can use [5]byte for example). Oh ... you actually need it to be a red-black tree, or a custom hash function ? Tough.