rust/src/liballoc
kennytm 2712fbed24
Rollup merge of #52116 - Pazzaz:match-str-case, r=SimonSapin
Handle array manually in str case conversion methods

Avoiding the overhead incurred from `String.extend(char.to_lowercase())` showed a notable performance improvement when I benchmarked it.

I tested on these strings:
```rust
ALL_LOWER:       "loremipsumdolorsitametduosensibusmnesarchumabcdefgh"
ALL_UPPER:       "LOREMIPSUMDOLORSITAMETDUOSENSIBUSMNESARCHUMABCDEFGH"
REALISTIC_UPPER: "LOREM IPSUM DOLOR SIT AMET, DUO SENSIBUS MNESARCHUM"
SIGMAS:          "ΣΣΣΣΣ ΣΣΣΣΣ ΣΣΣΣΣ ΣΣΣ ΣΣΣΣ, ΣΣΣ ΣΣΣΣΣΣΣΣ ΣΣΣΣΣΣΣΣΣΣ"
WORD_UPPER:      "Lorem Ipsum Dolor Sit Amet, Duo Sensibus Mnesarchum"
```
the performance improvements of `to_lowercase()` were
```
running 10 tests
test tests::all_lower           ... bench:       1,752 ns/iter (+/- 49)
test tests::all_lower_new       ... bench:       1,266 ns/iter (+/- 15)   -28%
test tests::all_upper           ... bench:       1,832 ns/iter (+/- 39)
test tests::all_upper_new       ... bench:       1,337 ns/iter (+/- 18)   -27%
test tests::realistic_upper     ... bench:       1,993 ns/iter (+/- 14)
test tests::realistic_upper_new ... bench:       1,445 ns/iter (+/- 22)   -27%
test tests::sigmas              ... bench:       1,342 ns/iter (+/- 39)
test tests::sigmas_new          ... bench:       1,226 ns/iter (+/- 16)    -9%
test tests::word_upper          ... bench:       1,899 ns/iter (+/- 12)
test tests::word_upper_new      ... bench:       1,381 ns/iter (+/- 26)   -27%
```
and of `to_uppercase()`
```
running 10 tests
test tests::all_lower           ... bench:       1,813 ns/iter (+/- 20)
test tests::all_lower_new       ... bench:       1,321 ns/iter (+/- 16)   -27%
test tests::all_upper           ... bench:       1,629 ns/iter (+/- 22)
test tests::all_upper_new       ... bench:       1,241 ns/iter (+/- 9)    -24%
test tests::realistic_upper     ... bench:       1,670 ns/iter (+/- 24)
test tests::realistic_upper_new ... bench:       1,241 ns/iter (+/- 17)   -26%
test tests::sigmas              ... bench:       2,053 ns/iter (+/- 20)
test tests::sigmas_new          ... bench:       1,753 ns/iter (+/- 23)   -15%
test tests::word_upper          ... bench:       1,873 ns/iter (+/- 30)
test tests::word_upper_new      ... bench:       1,412 ns/iter (+/- 25)   -25%
```
I gave up on the more advanced method from #52061 as it wasn't always a clear improvement and would help in even less cases if this PR was merged.
2018-07-18 22:34:54 +08:00
..
benches Move deny(warnings) into rustbuild 2018-04-08 16:59:14 -06:00
collections add outlives annotations to BTreeMap 2018-07-02 11:49:33 -04:00
tests Add some unit tests for dangling Weak references 2018-07-07 01:41:30 +02:00
alloc.rs Rename OOM to allocation error 2018-06-18 21:41:24 +02:00
borrow.rs Add #[must_use] to a few standard library methods 2018-03-30 23:06:05 -07:00
boxed.rs Revert borked changes in last commit. 2018-07-11 10:19:54 +02:00
boxed_test.rs Add missing dyn in liballoc 2018-07-10 22:32:19 +02:00
Cargo.toml Switch to 1.26 bootstrap compiler 2018-05-17 08:47:25 -06:00
fmt.rs Reexport fmt::Alignment into std 2018-06-03 17:04:48 +02:00
lib.rs Revert borked changes in last commit. 2018-07-11 10:19:54 +02:00
macros.rs fix some typos 2017-11-21 15:33:45 +01:00
prelude.rs Add the alloc::prelude module 2018-07-07 23:08:43 +02:00
raw_vec.rs Move core::alloc::CollectionAllocErr to alloc::collections 2018-06-29 14:01:33 +02:00
rc.rs Revert borked changes in last commit. 2018-07-11 10:19:54 +02:00
repeat-generic-slice.rs Add run-pass test for repeat-generic-slice feature 2018-03-28 09:02:27 +02:00
slice.rs Rollup merge of #51147 - tmccombs:sliceindex, r=SimonSapin 2018-06-02 13:14:25 -06:00
str.rs Handle array manually in string case conversion methods 2018-07-06 17:20:39 +02:00
string.rs Move core::alloc::CollectionAllocErr to alloc::collections 2018-06-29 14:01:33 +02:00
sync.rs Revert borked changes in last commit. 2018-07-11 10:19:54 +02:00
task.rs #[cfg(target_has_atomic_cas)] -> #[cfg(target_has_atomic = "cas")] 2018-07-05 16:52:46 -05:00
vec.rs Removed a single trailing space. Oops. 2018-07-09 06:31:24 +02:00