4 ms·
It's similar. It's just not by word, but by entire string, assuming that strings are immutable, long enough, and the same string values are referenced often eno
by nine_k 2y ago
It's similar. It's just not by word, but by entire string, assuming that strings are immutable, long enough, and the same string values are referenced often enough.
On 64-bit machines though strings shorter than 8 bytes are better off not interned.
- jfoutz 2y agoas I read it, it's any struct! Not just strings. which is cool.
- TheDong 2y agoAny "comparable" struct, which is to say any struct where '==' works. No, you can't override '=='. This will not work for the average struct, and if you do use it, you now no longer can include any, for example `[]byte` fields in the struct or else it will no longer compile. I always find it funny that `string` is comparable, but `[]rune` and `[]byte` are not.
- aatd86 2y agoIt's beczuse string values are immutable so at any point in a program, the result of string variable comparison would be the same. For slice types it's more complex because there is mutability implicit aliasing. And the backing array pointed at may change. I guess the latter should point us toward deep value comparison for slice types since any other comparison would be quite flimsy.