mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2025-04-24 17:12:16 +02:00
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:
parent
5dc424d302
commit
cddb5f57f8
9
Cargo.lock
generated
9
Cargo.lock
generated
@ -192,6 +192,7 @@ dependencies = [
|
|||||||
"grep-searcher",
|
"grep-searcher",
|
||||||
"log",
|
"log",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_derive",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
]
|
]
|
||||||
@ -458,18 +459,18 @@ checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.188"
|
version = "1.0.193"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "cf9e0fcba69a370eed61bcf2b728575f726b50b55cba78064753d708ddc7549e"
|
checksum = "25dd9975e68d0cb5aa1120c288333fc98731bd1dd12f561e468ea4728c042b89"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.188"
|
version = "1.0.193"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "4eca7ac642d82aa35b60049a6eccb4be6be75e599bd2e9adb5f875a737654af2"
|
checksum = "43576ca501357b9b071ac53cdc7da8ef0cbd9493d8df094cd821777ea6e894d3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
|
@ -16,7 +16,7 @@ edition = "2021"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["serde"]
|
default = ["serde"]
|
||||||
serde = ["dep:base64", "dep:serde", "dep:serde_json"]
|
serde = ["dep:base64", "dep:serde", "dep:serde_derive", "dep:serde_json"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
base64 = { version = "0.21.4", optional = true }
|
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" }
|
grep-searcher = { version = "0.1.11", path = "../searcher" }
|
||||||
log = "0.4.5"
|
log = "0.4.5"
|
||||||
termcolor = "1.3.0"
|
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 }
|
serde_json = { version = "1.0.107", optional = true }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
|
@ -8,10 +8,7 @@
|
|||||||
|
|
||||||
use std::{borrow::Cow, path::Path};
|
use std::{borrow::Cow, path::Path};
|
||||||
|
|
||||||
use {
|
use {base64, serde::Serializer, serde_derive::Serialize};
|
||||||
base64,
|
|
||||||
serde::{Serialize, Serializer},
|
|
||||||
};
|
|
||||||
|
|
||||||
use crate::stats::Stats;
|
use crate::stats::Stats;
|
||||||
|
|
||||||
@ -132,6 +129,7 @@ where
|
|||||||
T: AsRef<[u8]>,
|
T: AsRef<[u8]>,
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
|
use serde::Serialize;
|
||||||
Data::from_bytes(bytes.as_ref()).serialize(ser)
|
Data::from_bytes(bytes.as_ref()).serialize(ser)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -140,5 +138,6 @@ where
|
|||||||
P: AsRef<Path>,
|
P: AsRef<Path>,
|
||||||
S: Serializer,
|
S: Serializer,
|
||||||
{
|
{
|
||||||
|
use serde::Serialize;
|
||||||
path.as_ref().map(|p| Data::from_path(p.as_ref())).serialize(ser)
|
path.as_ref().map(|p| Data::from_path(p.as_ref())).serialize(ser)
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ use crate::util::NiceDuration;
|
|||||||
/// When statistics are reported by a printer, they correspond to all searches
|
/// When statistics are reported by a printer, they correspond to all searches
|
||||||
/// executed with that printer.
|
/// executed with that printer.
|
||||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||||
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
|
#[cfg_attr(feature = "serde", derive(serde_derive::Serialize))]
|
||||||
pub struct Stats {
|
pub struct Stats {
|
||||||
elapsed: NiceDuration,
|
elapsed: NiceDuration,
|
||||||
searches: u64,
|
searches: u64,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user