1
Fork 0
rust/library/alloc/src
bors 86bd45979a Auto merge of #130223 - LaihoE:faster_str_replace, r=thomcc
optimize str.replace

Adds a fast path for str.replace for the ascii to ascii case. This allows for autovectorizing the code. Also should this instead be done with specialization? This way we could remove one branch. I think it is the kind of branch that is easy to predict though.

Benchmark for the fast path (replace all "a" with "b" in the rust wikipedia article, using criterion) :
| N        | Speedup | Time New (ns) | Time Old (ns) |
|----------|---------|---------------|---------------|
| 2        | 2.03    | 13.567        | 27.576        |
| 8        | 1.73    | 17.478        | 30.259        |
| 11       | 2.46    | 18.296        | 45.055        |
| 16       | 2.71    | 17.181        | 46.526        |
| 37       | 4.43    | 18.526        | 81.997        |
| 64       | 8.54    | 18.670        | 159.470       |
| 200      | 9.82    | 29.634        | 291.010       |
| 2000     | 24.34   | 81.114        | 1974.300      |
| 20000    | 30.61   | 598.520       | 18318.000     |
| 1000000  | 29.31   | 33458.000     | 980540.000    |
2024-10-17 16:20:02 +00:00
..
alloc Reformat use declarations. 2024-07-29 08:26:52 +10:00
boxed Use &raw in the standard library 2024-09-25 17:03:20 -07:00
collections Auto merge of #126557 - GrigorenkoPV:vec_track_caller, r=joboet 2024-10-14 02:33:40 +00:00
ffi Rollup merge of #130608 - YohDeadfall:cstr-from-into-str, r=workingjubilee 2024-10-15 05:12:34 +02:00
raw_vec Polymorphize RawVec 2024-08-09 20:06:26 -04:00
rc Add str.as_str() for easy dereferencing of Box<str> 2024-09-19 16:25:56 +01:00
sync Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
testing Reformat use declarations. 2024-07-29 08:26:52 +10:00
vec Auto merge of #126557 - GrigorenkoPV:vec_track_caller, r=joboet 2024-10-14 02:33:40 +00:00
alloc.rs read_volatile __rust_no_alloc_shim_is_unstable in alloc_zeroed 2024-09-17 22:26:21 -04:00
borrow.rs remove const_cow_is_borrowed feature gate 2024-10-12 19:48:28 +02:00
boxed.rs allocate before calling T::default in <Box<T>>::default() 2024-10-10 09:49:24 -04:00
fmt.rs Reformat using the new identifier sorting from rustfmt 2024-09-22 19:11:29 -04:00
lib.miri.rs add 'x.py miri', and make it work for 'library/{core,alloc,std}' 2024-04-03 20:27:20 +02:00
lib.rs Auto merge of #131767 - cuviper:bump-stage0, r=Mark-Simulacrum 2024-10-16 14:40:08 +00:00
macros.rs Mark format! with must_use hint 2024-07-06 14:24:20 +02:00
raw_vec.rs Auto merge of #126557 - GrigorenkoPV:vec_track_caller, r=joboet 2024-10-14 02:33:40 +00:00
rc.rs rename rcbox in other places as per review comments 2024-10-13 21:25:00 +02:00
slice.rs Port sort-research-rs test suite Rust stdlib tests 2024-09-30 15:05:30 +02:00
str.rs Auto merge of #130223 - LaihoE:faster_str_replace, r=thomcc 2024-10-17 16:20:02 +00:00
string.rs Auto merge of #130223 - LaihoE:faster_str_replace, r=thomcc 2024-10-17 16:20:02 +00:00
sync.rs Auto merge of #131460 - jwong101:default-placement-new, r=ibraheemdev 2024-10-16 06:36:43 +00:00
task.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00
tests.rs Reformat use declarations. 2024-07-29 08:26:52 +10:00