printer: rejigger how we use serde_derive

The idea is that by bringing derives in via serde's optional feature, it
was inhibiting compilation speed[1]. We try to fix that by depending on
`serde_derive` as a distinct dependency.

It does seem to improve overall compilation time, but only by about 0.5
seconds. With that said, my machine has a lot of cores, so it's possible
this will help more on less powerful CPUs.

[1]: https://old.reddit.com/r/rust/comments/17rd8ww/faster_compilation_with_the_parallel_frontend_in/k8igjlg/
This commit is contained in:
Andrew Gallant
2023-11-21 08:10:04 -05:00
parent 5dc424d302
commit cddb5f57f8
4 changed files with 12 additions and 11 deletions

View File

@@ -8,10 +8,7 @@
use std::{borrow::Cow, path::Path};
use {
base64,
serde::{Serialize, Serializer},
};
use {base64, serde::Serializer, serde_derive::Serialize};
use crate::stats::Stats;
@@ -132,6 +129,7 @@ where
T: AsRef<[u8]>,
S: Serializer,
{
use serde::Serialize;
Data::from_bytes(bytes.as_ref()).serialize(ser)
}
@@ -140,5 +138,6 @@ where
P: AsRef<Path>,
S: Serializer,
{
use serde::Serialize;
path.as_ref().map(|p| Data::from_path(p.as_ref())).serialize(ser)
}

View File

@@ -10,7 +10,7 @@ use crate::util::NiceDuration;
/// When statistics are reported by a printer, they correspond to all searches
/// executed with that printer.
#[derive(Clone, Debug, Default, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "serde", derive(serde_derive::Serialize))]
pub struct Stats {
elapsed: NiceDuration,
searches: u64,