Auto merge of #69256 - nnethercote:misc-inlining, r=Centril
Miscellaneous inlining improvements These commits inline some hot functions that aren't currently inlined, for some speed wins. r? @Centril
This commit is contained in:
commit
183e893aaa
@ -1499,7 +1499,7 @@ fn contains_nonascii(x: usize) -> bool {
|
||||
|
||||
/// Walks through `v` checking that it's a valid UTF-8 sequence,
|
||||
/// returning `Ok(())` in that case, or, if it is invalid, `Err(err)`.
|
||||
#[inline]
|
||||
#[inline(always)]
|
||||
fn run_utf8_validation(v: &[u8]) -> Result<(), Utf8Error> {
|
||||
let mut index = 0;
|
||||
let len = v.len();
|
||||
|
@ -993,6 +993,7 @@ fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
|
||||
}
|
||||
|
||||
impl Decodable for Symbol {
|
||||
#[inline]
|
||||
fn decode<D: Decoder>(d: &mut D) -> Result<Symbol, D::Error> {
|
||||
Ok(Symbol::intern(&d.read_str()?))
|
||||
}
|
||||
@ -1031,6 +1032,7 @@ fn prefill(init: &[&'static str]) -> Self {
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn intern(&mut self, string: &str) -> Symbol {
|
||||
if let Some(&name) = self.names.get(string) {
|
||||
return name;
|
||||
|
@ -36,6 +36,7 @@ pub trait Encoder {
|
||||
fn emit_str(&mut self, v: &str) -> Result<(), Self::Error>;
|
||||
|
||||
// Compound types:
|
||||
#[inline]
|
||||
fn emit_enum<F>(&mut self, _name: &str, f: F) -> Result<(), Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||
@ -57,6 +58,7 @@ fn emit_enum_variant<F>(
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn emit_enum_variant_arg<F>(&mut self, _a_idx: usize, f: F) -> Result<(), Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||
@ -89,6 +91,7 @@ fn emit_enum_struct_variant_field<F>(
|
||||
self.emit_enum_variant_arg(f_idx, f)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn emit_struct<F>(&mut self, _name: &str, _len: usize, f: F) -> Result<(), Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||
@ -96,6 +99,7 @@ fn emit_struct<F>(&mut self, _name: &str, _len: usize, f: F) -> Result<(), Self:
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn emit_struct_field<F>(
|
||||
&mut self,
|
||||
_f_name: &str,
|
||||
@ -108,6 +112,7 @@ fn emit_struct_field<F>(
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn emit_tuple<F>(&mut self, _len: usize, f: F) -> Result<(), Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||
@ -115,6 +120,7 @@ fn emit_tuple<F>(&mut self, _len: usize, f: F) -> Result<(), Self::Error>
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn emit_tuple_arg<F>(&mut self, _idx: usize, f: F) -> Result<(), Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||
@ -164,6 +170,7 @@ fn emit_seq<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error>
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn emit_seq_elt<F>(&mut self, _idx: usize, f: F) -> Result<(), Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||
@ -179,6 +186,7 @@ fn emit_map<F>(&mut self, len: usize, f: F) -> Result<(), Self::Error>
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn emit_map_elt_key<F>(&mut self, _idx: usize, f: F) -> Result<(), Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||
@ -186,6 +194,7 @@ fn emit_map_elt_key<F>(&mut self, _idx: usize, f: F) -> Result<(), Self::Error>
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn emit_map_elt_val<F>(&mut self, _idx: usize, f: F) -> Result<(), Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<(), Self::Error>,
|
||||
@ -218,6 +227,7 @@ pub trait Decoder {
|
||||
fn read_str(&mut self) -> Result<Cow<'_, str>, Self::Error>;
|
||||
|
||||
// Compound types:
|
||||
#[inline]
|
||||
fn read_enum<T, F>(&mut self, _name: &str, f: F) -> Result<T, Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<T, Self::Error>,
|
||||
@ -225,6 +235,7 @@ fn read_enum<T, F>(&mut self, _name: &str, f: F) -> Result<T, Self::Error>
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_enum_variant<T, F>(&mut self, _names: &[&str], mut f: F) -> Result<T, Self::Error>
|
||||
where
|
||||
F: FnMut(&mut Self, usize) -> Result<T, Self::Error>,
|
||||
@ -233,6 +244,7 @@ fn read_enum_variant<T, F>(&mut self, _names: &[&str], mut f: F) -> Result<T, Se
|
||||
f(self, disr)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_enum_variant_arg<T, F>(&mut self, _a_idx: usize, f: F) -> Result<T, Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<T, Self::Error>,
|
||||
@ -259,6 +271,7 @@ fn read_enum_struct_variant_field<T, F>(
|
||||
self.read_enum_variant_arg(f_idx, f)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_struct<T, F>(&mut self, _s_name: &str, _len: usize, f: F) -> Result<T, Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<T, Self::Error>,
|
||||
@ -266,6 +279,7 @@ fn read_struct<T, F>(&mut self, _s_name: &str, _len: usize, f: F) -> Result<T, S
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_struct_field<T, F>(
|
||||
&mut self,
|
||||
_f_name: &str,
|
||||
@ -278,6 +292,7 @@ fn read_struct_field<T, F>(
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_tuple<T, F>(&mut self, _len: usize, f: F) -> Result<T, Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<T, Self::Error>,
|
||||
@ -285,6 +300,7 @@ fn read_tuple<T, F>(&mut self, _len: usize, f: F) -> Result<T, Self::Error>
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_tuple_arg<T, F>(&mut self, _a_idx: usize, f: F) -> Result<T, Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<T, Self::Error>,
|
||||
@ -328,6 +344,7 @@ fn read_seq<T, F>(&mut self, f: F) -> Result<T, Self::Error>
|
||||
f(self, len)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_seq_elt<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<T, Self::Error>,
|
||||
@ -343,6 +360,7 @@ fn read_map<T, F>(&mut self, f: F) -> Result<T, Self::Error>
|
||||
f(self, len)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_map_elt_key<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<T, Self::Error>,
|
||||
@ -350,6 +368,7 @@ fn read_map_elt_key<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Self::Error
|
||||
f(self)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn read_map_elt_val<T, F>(&mut self, _idx: usize, f: F) -> Result<T, Self::Error>
|
||||
where
|
||||
F: FnOnce(&mut Self) -> Result<T, Self::Error>,
|
||||
|
Loading…
Reference in New Issue
Block a user