4 ms·
I tried it using String instead of StringView and it didn't do the comparison optimisation either. For GCC it did inline one of the comparisons (https://godbolt
by benmmurphy 4y ago
I tried it using String instead of StringView and it didn't do the comparison optimisation either. For GCC it did inline one of the comparisons (https://godbolt.org/z/G3Ydfoxqc https://godbolt.org/z/G3Ydfoxqc). Probably, its not possible to do the optimisation with the standard library because the standard library doesn't guarantee that small strings will be in small string form so you always have to fallback on failure. Also, it doesn't work for swift because swift string comparison is based on some kind of normalisation. So there is a fast path check using the small string optimisation but if that fails it falls back to a slow check that tries to do normalisation. (https://swift.godbolt.org/z/fscsarGjb https://swift.godbolt.org/z/fscsarGjb)