diff options
| author | bors <bors@rust-lang.org> | 2019-04-05 12:13:52 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2019-04-05 12:13:52 +0000 |
| commit | 4d7defb26584b0d4e5cad372b2ab8888bfc22f3a (patch) | |
| tree | 701541189e7d5651cb6553be6b8bdaf4ec881559 /src/libstd | |
| parent | a781c47243a5ebde3f84a9635ffddd1cfc82ed9c (diff) | |
| parent | 7249036de5c6a2e8aad93512e3f529f3024d03e5 (diff) | |
| download | rust-4d7defb26584b0d4e5cad372b2ab8888bfc22f3a.tar.gz rust-4d7defb26584b0d4e5cad372b2ab8888bfc22f3a.zip | |
Auto merge of #59721 - Centril:rollup-ieam9ke, r=Centril
Rollup of 5 pull requests Successful merges: - #59665 (improve worst-case performance of HashSet.is_subset) - #59687 (cleanup shebang handling in the lexer) - #59690 (Mark unix::ffi::OsStrExt methods as inline) - #59702 (Use declare_lint_pass! and impl_lint_pass! in more places) - #59712 (wasm32: Default to a "static" relocation model) Failed merges: r? @ghost
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/collections/hash/set.rs | 6 | ||||
| -rw-r--r-- | src/libstd/ffi/os_str.rs | 1 | ||||
| -rw-r--r-- | src/libstd/sys_common/os_str_bytes.rs | 2 |
3 files changed, 8 insertions, 1 deletions
diff --git a/src/libstd/collections/hash/set.rs b/src/libstd/collections/hash/set.rs index 89d5b2ff30f..b9fcc2365fa 100644 --- a/src/libstd/collections/hash/set.rs +++ b/src/libstd/collections/hash/set.rs @@ -627,7 +627,11 @@ impl<T, S> HashSet<T, S> /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn is_subset(&self, other: &HashSet<T, S>) -> bool { - self.iter().all(|v| other.contains(v)) + if self.len() <= other.len() { + self.iter().all(|v| other.contains(v)) + } else { + false + } } /// Returns `true` if the set is a superset of another, diff --git a/src/libstd/ffi/os_str.rs b/src/libstd/ffi/os_str.rs index 01e7a57cd00..13aee783750 100644 --- a/src/libstd/ffi/os_str.rs +++ b/src/libstd/ffi/os_str.rs @@ -960,6 +960,7 @@ impl IntoInner<Buf> for OsString { } impl AsInner<Slice> for OsStr { + #[inline] fn as_inner(&self) -> &Slice { &self.inner } diff --git a/src/libstd/sys_common/os_str_bytes.rs b/src/libstd/sys_common/os_str_bytes.rs index 7cc93477a73..a4961974d89 100644 --- a/src/libstd/sys_common/os_str_bytes.rs +++ b/src/libstd/sys_common/os_str_bytes.rs @@ -236,9 +236,11 @@ pub trait OsStrExt { #[stable(feature = "rust1", since = "1.0.0")] impl OsStrExt for OsStr { + #[inline] fn from_bytes(slice: &[u8]) -> &OsStr { unsafe { mem::transmute(slice) } } + #[inline] fn as_bytes(&self) -> &[u8] { &self.as_inner().inner } |
