about summary refs log tree commit diff
path: root/library/std/src/sys_common/wtf8
AgeCommit message (Collapse)AuthorLines
2022-06-23Remove `is_known_utf8` checks from more tests where it's no longer set.Dan Gohman-4/+0
2022-06-23Don't eagerly scan for `is_known_utf8` in `to_ascii_lowercase`/`uppercase`.Dan Gohman-4/+0
2022-06-23Optimize `Wtf8Buf::into_string` for the case where it contains UTF-8.Dan Gohman-19/+284
Add a `is_known_utf8` flag to `Wtf8Buf`, which tracks whether the string is known to contain UTF-8. This is efficiently computed in many common situations, such as when a `Wtf8Buf` is constructed from a `String` or `&str`, or with `Wtf8Buf::from_wide` which is already doing UTF-16 decoding and already checking for surrogates. This makes `OsString::into_string` O(1) rather than O(N) on Windows in common cases. And, it eliminates the need to scan through the string for surrogates in `Args::next` and `Vars::next`, because the strings are already being translated with `Wtf8Buf::from_wide`. Many things on Windows construct `OsString`s with `Wtf8Buf::from_wide`, such as `DirEntry::file_name` and `fs::read_link`, so with this patch, users of those functions can subsequently call `.into_string()` without paying for an extra scan through the string for surrogates.
2022-03-10Use implicit capture syntax in format_argsT-O-R-U-S-2/+2
This updates the standard library's documentation to use the new syntax. The documentation is worthwhile to update as it should be more idiomatic (particularly for features like this, which are nice for users to get acquainted with). The general codebase is likely more hassle than benefit to update: it'll hurt git blame, and generally updates can be done by folks updating the code if (and when) that makes things more readable with the new format. A few places in the compiler and library code are updated (mostly just due to already having been done when this commit was first authored).
2021-06-20Auto merge of #86463 - fee1-dead:fixed-encode_wide, r=m-ou-sebors-0/+12
Account for self.extra in size_hint for EncodeWide Fixes #86414.
2021-06-19Account for self.extra in size_hint for EncodeWideDeadbeef-0/+12
2021-06-18Lint for unused borrows as part of UNUSED_MUST_USEhi-rustin-3/+3
2020-08-31std: move "mod tests/benches" to separate filesLzu Tao-0/+397
Also doing fmt inplace as requested.