summaryrefslogtreecommitdiffstats
path: root/crates
diff options
context:
space:
mode:
authorAndrew Gallant <jamslam@gmail.com>2023-11-21 08:10:04 -0500
committerAndrew Gallant <jamslam@gmail.com>2023-11-21 18:39:32 -0500
commitcddb5f57f8fa3413a6210bdd3a8f687b7dac69b2 (patch)
tree6d0f5a5cd0ad02ce4b35ec7f52c9106444a10804 /crates
parent5dc424d3027be8fac4831a55f31b5a91bd0e5312 (diff)
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/
Diffstat (limited to 'crates')
-rw-r--r--crates/printer/Cargo.toml5
-rw-r--r--crates/printer/src/jsont.rs7
-rw-r--r--crates/printer/src/stats.rs2
3 files changed, 7 insertions, 7 deletions
diff --git a/crates/printer/Cargo.toml b/crates/printer/Cargo.toml
index dc63a6cc..4193d3d1 100644
--- a/crates/printer/Cargo.toml
+++ b/crates/printer/Cargo.toml
@@ -16,7 +16,7 @@ edition = "2021"
[features]
default = ["serde"]
-serde = ["dep:base64", "dep:serde", "dep:serde_json"]
+serde = ["dep:base64", "dep:serde", "dep:serde_derive", "dep:serde_json"]
[dependencies]
base64 = { version = "0.21.4", optional = true }
@@ -25,7 +25,8 @@ grep-matcher = { version = "0.1.6", path = "../matcher" }
grep-searcher = { version = "0.1.11", path = "../searcher" }
log = "0.4.5"
termcolor = "1.3.0"
-serde = { version = "1.0.188", optional = true, features = ["derive"] }
+serde = { version = "1.0.193", optional = true }
+serde_derive = { version = "1.0.193", optional = true }
serde_json = { version = "1.0.107", optional = true }
[dev-dependencies]
diff --git a/crates/printer/src/jsont.rs b/crates/printer/src/jsont.rs
index 5f67f115..5d901041 100644
--- a/crates/printer/src/jsont.rs
+++ b/crates/printer/src/jsont.rs
@@ -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)
}
diff --git a/crates/printer/src/stats.rs b/crates/printer/src/stats.rs
index 9aa14d46..f1898c0b 100644
--- a/crates/printer/src/stats.rs
+++ b/crates/printer/src/stats.rs
@@ -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,