Files
rust/src/libcore
Manish Goregaokar 1979fa86f9 Rollup merge of #74066 - thomcc:optimize-is-ascii, r=nagisa
Optimize is_ascii for str and [u8].

This optimizes the `is_ascii` function for `[u8]` and `str`. I've been surprised this wasn't done for a while, so I just did it.

Benchmarks comparing before/after look like:

```
test ascii::long_readonly::is_ascii_slice_iter_all              ... bench:         174 ns/iter (+/- 79) = 40172 MB/s
test ascii::long_readonly::is_ascii_slice_libcore               ... bench:          16 ns/iter (+/- 5) = 436875 MB/s
test ascii::medium_readonly::is_ascii_slice_iter_all            ... bench:          12 ns/iter (+/- 3) = 2666 MB/s
test ascii::medium_readonly::is_ascii_slice_libcore             ... bench:           2 ns/iter (+/- 0) = 16000 MB/s
test ascii::short_readonly::is_ascii_slice_iter_all             ... bench:           3 ns/iter (+/- 0) = 2333 MB/s
test ascii::short_readonly::is_ascii_slice_libcore              ... bench:           4 ns/iter (+/- 0) = 1750 MB/s
```

(Taken on a x86_64 macbook 2.9 GHz Intel Core i9 with 6 cores)

Where `is_ascii_slice_iter_all` is the old version, and `is_ascii_slice_libcore` is the new.

I tried to document the code well, so hopefully it's understandable. It has fairly exhaustive tests ensuring size/align doesn't get violated -- because `miri` doesn't really help a lot for this sort of code right now, I tried to `debug_assert` all the safety invariants I'm depending on. (Of course, none of them are required for correctness or soundness -- just allows us to test that this sort of pointer manipulation is sound and such).

Anyway, thanks. Let me know if you have questions/desired changes.
2020-07-11 08:53:16 -07:00
..
2020-07-05 15:23:42 +08:00
2020-06-24 19:08:11 -04:00
2020-04-25 09:25:33 -04:00
2020-06-30 19:28:51 +02:00
2020-07-05 10:23:50 -07:00
2020-05-12 16:54:29 +01:00
2019-11-26 23:02:11 -08:00
2019-12-22 17:42:47 -05:00
2020-06-18 09:11:15 -07:00
2020-06-30 19:28:51 +02:00
2020-04-25 09:25:33 -04:00
2020-06-12 23:52:52 +02:00
2020-07-10 07:39:28 -04:00
2020-06-30 19:28:51 +02:00
2020-07-03 17:21:20 +02:00
2020-06-25 23:08:58 +01:00
2020-06-30 22:22:32 -07:00
2020-06-30 19:28:51 +02:00
2020-02-23 23:59:39 -08:00
2020-06-20 12:27:16 -07:00
2020-06-20 10:55:39 -04:00
2019-11-26 23:02:11 -08:00
2019-11-26 23:02:11 -08:00