perf(serde): Use Formatter.write_str when writing string literals

This commit is contained in:
Constantin Nickel 2021-10-28 11:48:40 +02:00
parent bf6ffe67f6
commit f2f7882e1b
5 changed files with 9 additions and 9 deletions

View File

@ -1280,7 +1280,7 @@ pub mod serde {
type Value = DateTime<FixedOffset>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a formatted date and time string or a unix timestamp")
formatter.write_str("a formatted date and time string or a unix timestamp")
}
fn visit_str<E>(self, value: &str) -> Result<DateTime<FixedOffset>, E>
@ -1462,7 +1462,7 @@ pub mod serde {
type Value = DateTime<Utc>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a unix timestamp in nanoseconds")
formatter.write_str("a unix timestamp in nanoseconds")
}
/// Deserialize a timestamp in nanoseconds since the epoch
@ -1772,7 +1772,7 @@ pub mod serde {
type Value = DateTime<Utc>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a unix timestamp in microseconds")
formatter.write_str("a unix timestamp in microseconds")
}
/// Deserialize a timestamp in milliseconds since the epoch
@ -1929,7 +1929,7 @@ pub mod serde {
type Value = Option<DateTime<Utc>>;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a unix timestamp in microseconds or none")
formatter.write_str("a unix timestamp in microseconds or none")
}
/// Deserialize a timestamp in seconds since the epoch

View File

@ -867,7 +867,7 @@ mod weekday_serde {
type Value = Weekday;
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Weekday")
f.write_str("Weekday")
}
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>
@ -1169,7 +1169,7 @@ mod month_serde {
type Value = Month;
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Month")
f.write_str("Month")
}
fn visit_str<E>(self, value: &str) -> Result<Self::Value, E>

View File

@ -1844,7 +1844,7 @@ mod serde {
type Value = NaiveDate;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a formatted date string")
formatter.write_str("a formatted date string")
}
#[cfg(any(feature = "std", test))]

View File

@ -1751,7 +1751,7 @@ pub mod serde {
type Value = NaiveDateTime;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a formatted date and time string")
formatter.write_str("a formatted date and time string")
}
fn visit_str<E>(self, value: &str) -> Result<NaiveDateTime, E>

View File

@ -1490,7 +1490,7 @@ mod serde {
type Value = NaiveTime;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
write!(formatter, "a formatted time string")
formatter.write_str("a formatted time string")
}
fn visit_str<E>(self, value: &str) -> Result<NaiveTime, E>