about summary refs log tree commit diff
path: root/library/core/src/str/pattern.rs
AgeCommit message (Collapse)AuthorLines
2025-07-29LoongArch64 LSX fast-path for `str.contains(&str)`WANG Rui-3/+16
Benchmark results with LLVM 21 on LA664: ``` OLD: test bench_is_contained_in ... bench: 43.63 ns/iter (+/- 0.04) NEW: test bench_is_contained_in ... bench: 12.81 ns/iter (+/- 0.01) ```
2025-05-28Revert "increase perf of charsearcher for single ascii characters"Jakub Beránek-31/+1
This reverts commit 245bf503e2a948ac98170516d11df632e85a948b.
2025-05-26increase perf of charsearcher for single ascii charactersbendn-1/+31
2025-03-15Optimize multi-char string patternsYotam Ofek-3/+3
2025-02-16add MAX_LEN_UTF8 and MAX_LEN_UTF16 constantsHTGAzureX1212-2/+3
2024-11-04Improve example of `impl Pattern for &[char]`Eduardo Sánchez Muñoz-2/+2
The previous version used `['l', 'l']` as pattern, which would suggest that it matches the `ll` of `Hello world` as a whole.
2024-10-25library: consistently use American spelling for 'behavior'Ralf Jung-2/+2
2024-10-24provide default impl for as_utf8_patternLaiho-11/+3
2024-09-23Add fast path for ascii to ascii in str::replaceLaiho-0/+33
2024-09-08Remove needless returns detected by clippy in librariesEduardo Sánchez Muñoz-2/+2
2024-07-29Reformat `use` declarations.Nicholas Nethercote-4/+2
The previous commit updated `rustfmt.toml` appropriately. This commit is the outcome of running `x fmt --all` with the new formatting options.
2024-07-15Remove generic lifetime parameter of trait `Pattern`Benoît du Garreau-63/+69
Use a GAT for `Searcher` associated type because this trait is always implemented for every lifetime anyway.
2024-06-02typo: depending from -> onRalf Jung-1/+1
2024-02-13Store core::str::CharSearcher::utf8_size as u8GnomedDev-11/+23
2023-11-26Update std::simd usage and test outputsCaleb Zulawski-9/+9
2023-11-26Fix library testsCaleb Zulawski-1/+1
2023-11-17Auto merge of #111922 - vaporoxx:feat-searcher, r=dtolnaybors-0/+4
feat: implement `DoubleEndedSearcher` for `CharArray[Ref]Searcher` This PR implements `DoubleEndedSearcher` for both `CharArraySearcher` and `CharArrayRefSearcher`. I'm not sure whether this was just overlooked or if there is a reason for it, but since it behaves exactly like `CharSliceSearcher`, I think the implementations should be appropriate.
2023-07-12Re-format let-else per rustfmt updateMark Rousskov-1/+3
2023-05-24feat: implement `DoubleEndedSearcher` for `CharArray[Ref]Searcher`Jan-0/+4
2023-05-14Fix some misleading and copy-pasted `Pattern` examplesScott McMurray-4/+4
These examples were listed twice and also were confusable with doing a substring match instead of a any-of-set match.
2023-04-10Fix typos in libraryDaniPopes-1/+1
2022-12-05fix dupe word typosRageking8-1/+1
2022-11-22fix OOB access in SIMD impl of str.contains()The 8472-4/+6
2022-11-15- convert from core::arch to core::simdThe 8472-52/+182
- bump simd compare to 32bytes - import small slice compare code from memmem crate - try a few different probe bytes to avoid degenerate cases - but special-case 2-byte needles
2022-11-14x86_64 SSE2 fast-path for str.contains(&str) and short needlesThe 8472-0/+102
Based on Wojciech Muła's "SIMD-friendly algorithms for substring searching"[0] The two-way algorithm is Big-O efficient but it needs to preprocess the needle to find a "criticla factorization" of it. This additional work is significant for short needles. Additionally it mostly advances needle.len() bytes at a time. The SIMD-based approach used here on the other hand can advance based on its vector width, which can exceed the needle length. Except for pathological cases, but due to being limited to small needles the worst case blowup is also small. benchmarks taken on a Zen2: ``` 16CGU, OLD: test str::bench_contains_short_short ... bench: 27 ns/iter (+/- 1) test str::bench_contains_short_long ... bench: 667 ns/iter (+/- 29) test str::bench_contains_bad_naive ... bench: 131 ns/iter (+/- 2) test str::bench_contains_bad_simd ... bench: 130 ns/iter (+/- 2) test str::bench_contains_equal ... bench: 148 ns/iter (+/- 4) 16CGU, NEW: test str::bench_contains_short_short ... bench: 8 ns/iter (+/- 0) test str::bench_contains_short_long ... bench: 135 ns/iter (+/- 4) test str::bench_contains_bad_naive ... bench: 130 ns/iter (+/- 2) test str::bench_contains_bad_simd ... bench: 292 ns/iter (+/- 1) test str::bench_contains_equal ... bench: 3 ns/iter (+/- 0) 1CGU, OLD: test str::bench_contains_short_short ... bench: 30 ns/iter (+/- 0) test str::bench_contains_short_long ... bench: 713 ns/iter (+/- 17) test str::bench_contains_bad_naive ... bench: 131 ns/iter (+/- 3) test str::bench_contains_bad_simd ... bench: 130 ns/iter (+/- 3) test str::bench_contains_equal ... bench: 148 ns/iter (+/- 6) 1CGU, NEW: test str::bench_contains_short_short ... bench: 10 ns/iter (+/- 0) test str::bench_contains_short_long ... bench: 111 ns/iter (+/- 0) test str::bench_contains_bad_naive ... bench: 135 ns/iter (+/- 3) test str::bench_contains_bad_simd ... bench: 274 ns/iter (+/- 2) test str::bench_contains_equal ... bench: 4 ns/iter (+/- 0) ``` [0] http://0x80.pl/articles/simd-strfind.html#sse-avx2
2022-10-17Fix typo in `ReverseSearcher` docsSky-1/+1
2021-07-28Add char array without ref Pattern implCameron Steffen-4/+37
2021-07-28impl Pattern for char arrayCameron Steffen-0/+40
2021-07-11Fix #85462 by adding a marker flagAlexis Bourget-2/+17
This will not affect ABI since the other variant of the enum is bigger. It may break some code, but that would be very strange: usually people don't continue after the first `Done` (or `None` for a normal iterator).
2020-09-18Fixed some intra-docs links in library/coreAmjad Alsharafi-1/+1
2020-08-22Add more linksGuillaume Gomez-46/+55
2020-08-21Convert links to intra-doc links formatGuillaume Gomez-11/+2
2020-07-27mv std libs to library/mark-0/+1598