| ▲ | logicchains 3 hours ago | |
Your handwritten one has a major performance bug:
Do you see it? It copies the v into a local variable, which could be tremendously wasteful if it's a large struct. You should instead be taking a pointer to s[i] and comparing the value there with `needle`.If you'd used `slices.Contains(s, needle)`, on the other hand, it could have such a performance bug in it and you'd never know. | ||
| ▲ | kajman an hour ago | parent | next [-] | |
> If you'd used `slices.Contains(s, needle)`, on the other hand, it could have such a performance bug in it and you'd never know. Perhaps you're much better at programming than I am, but I prefer these semantics in a language because I figure they're much more likely to have been optimized empirically, support vectorization, and be less buggy than another rote loop I'm trying to speed through. | ||
| ▲ | boredatoms an hour ago | parent | prev | next [-] | |
or contains() could be written by those who can write performant code, ..once | ||
| ▲ | mathisfun123 an hour ago | parent | prev [-] | |
> on the other hand, it could have such a performance bug in it and you'd never know. wut...? the debate isn't between closed (incompetent) source and open (competent) source - the debate is between verbose language and expressive language. | ||