diff --git a/tools/trace-parser/trace-tools/Cargo.lock b/tools/trace-parser/trace-tools/Cargo.lock index 06070420a7d95b1729b2edb5f9459e8c4f7272ec..5c1e709934acaaba7afbfa5a3c3c3d9f931ec512 100644 --- a/tools/trace-parser/trace-tools/Cargo.lock +++ b/tools/trace-parser/trace-tools/Cargo.lock @@ -1241,7 +1241,6 @@ dependencies = [ "nom-language", "nom_locate", "once_cell", - "smartstring", "thiserror", "thread_local", "zstd", diff --git a/tools/trace-parser/traceevent/Cargo.toml b/tools/trace-parser/traceevent/Cargo.toml index 7d22f613897a30e996e762202ff211e9a656e647..d6936724012646f3b7d7bd202e2a773655248cbc 100644 --- a/tools/trace-parser/traceevent/Cargo.toml +++ b/tools/trace-parser/traceevent/Cargo.toml @@ -8,7 +8,6 @@ edition = "2021" [dependencies] nom = "8.0" nom_locate = "5.0" -smartstring = "1.0" thiserror = "2.0" memmap2 = "0.9" deref-map = "0.1.0" @@ -23,3 +22,9 @@ bytemuck = "1.13" thread_local = "1.1" zstd = "0.13" nom-language = "0.1" + + +smartstring = {version = "1.0", optional = true } + +[features] +smartstring = ["dep:smartstring"] diff --git a/tools/trace-parser/traceevent/src/buffer.rs b/tools/trace-parser/traceevent/src/buffer.rs index 1a844df8a7395908d062e99675a28b204dd27993..13d34ec5b1579895be5affc4eacab9dcfde7a18c 100644 --- a/tools/trace-parser/traceevent/src/buffer.rs +++ b/tools/trace-parser/traceevent/src/buffer.rs @@ -32,7 +32,6 @@ use bytemuck::cast_slice; use deref_map::DerefMap; use genawaiter::{sync::gen, yield_}; use once_cell::unsync::OnceCell; -use smartstring::alias::String; use crate::{ array, @@ -50,7 +49,7 @@ use crate::{ iterator::MergedIterator, print::{PrintArg, PrintAtom, PrintFmtStr, PrintPrecision, PrintWidth, VBinSpecifier}, scratch::{ScratchAlloc, ScratchVec}, - str::Str, + str::{Str, String}, }; /// Keeps an [EventId] <-> ([EventDesc], [Ctx]) mapping so we can quickly access the decoder for diff --git a/tools/trace-parser/traceevent/src/cparser.rs b/tools/trace-parser/traceevent/src/cparser.rs index 828f21dd704f0b287fd766cd0a9fd761fbdea53a..dd6e1c57a2f5264c80a91ff42fe0be3b4e4de673 100644 --- a/tools/trace-parser/traceevent/src/cparser.rs +++ b/tools/trace-parser/traceevent/src/cparser.rs @@ -38,7 +38,6 @@ use nom::{ sequence::{delimited, pair, preceded, separated_pair, terminated}, AsBytes, Finish as _, Parser, }; -use smartstring::alias::String; use crate::{ cinterp::{ @@ -53,7 +52,7 @@ use crate::{ VerboseParseError, }, scratch::{OwnedScratchBox, ScratchVec}, - str::Str, + str::{Str, String}, }; /// Type of a C expression. diff --git a/tools/trace-parser/traceevent/src/header.rs b/tools/trace-parser/traceevent/src/header.rs index e99010d2b1f42b0f6c5bda694473755a14123013..46b245b57a513af07a937449b2511e7639352704 100644 --- a/tools/trace-parser/traceevent/src/header.rs +++ b/tools/trace-parser/traceevent/src/header.rs @@ -51,7 +51,6 @@ use nom::{ Finish as _, Parser, }; use once_cell::sync::OnceCell; -use smartstring::alias::String; use crate::{ array::Array, @@ -75,7 +74,7 @@ use crate::{ }, print::{PrintAtom, PrintFmtError, PrintFmtStr, PrintSpecifier, StringWriter}, scratch::{ScratchAlloc, ScratchVec}, - str::Str, + str::{Str, String}, }; /// Type alias for a memory address contained in the trace. diff --git a/tools/trace-parser/traceevent/src/print.rs b/tools/trace-parser/traceevent/src/print.rs index ae661a7a1b22bf508d0d14c5d5ec7569b81fcac3..c64593832a7a7fe2107bdd2bc3d41c6a392f9414 100644 --- a/tools/trace-parser/traceevent/src/print.rs +++ b/tools/trace-parser/traceevent/src/print.rs @@ -37,7 +37,6 @@ use nom::{ Parser, }; use once_cell::sync::OnceCell; -use smartstring::alias::String; use crate::{ buffer::{BufferError, VBinDecoder}, @@ -46,7 +45,7 @@ use crate::{ error::convert_err_impl, header::{Abi, Endianness, Header, LongSize, Signedness}, parser::{map_res_cut, FromParseError, NomParserExt as _, VerboseParseError}, - str::{InnerStr, Str}, + str::{InnerStr, Str, String}, }; /// Parsed printk-style format string. @@ -1363,7 +1362,7 @@ where if key { let merged_s = group .map(|x| match x { - PrintAtom::Fixed(s) => s, + PrintAtom::Fixed(s) => s.as_str(), _ => panic!("Expected fixed atom"), }) .collect(); diff --git a/tools/trace-parser/traceevent/src/str.rs b/tools/trace-parser/traceevent/src/str.rs index 3d3c64699be6958dff3771e0c918c8dcb988e57e..3ea521e506e79b6de7307e80d6d5bdc0e7eb9eba 100644 --- a/tools/trace-parser/traceevent/src/str.rs +++ b/tools/trace-parser/traceevent/src/str.rs @@ -16,8 +16,7 @@ //! Custom string type that fits all use cases inside this crate. //! -//! The main reason for a custom type are the various ownership models supported and using -//! [smartstring::alias::String] internally where possible. +//! The main reason for a custom type are the various ownership models supported. use core::{ borrow::Borrow, @@ -28,13 +27,17 @@ use core::{ }; use std::sync::Arc; -use smartstring::alias::String; - use crate::{ memo::Memo, scratch::{OwnedScratchBox, OwnedScratchBox_as_dyn, ScratchAlloc}, }; +#[cfg(feature = "smartstring")] +pub use smartstring::alias::String; + +#[cfg(not(feature = "smartstring"))] +pub use String; + /// String type with various ownership model available. #[derive(Debug, Clone)] pub struct Str<'a> { @@ -151,7 +154,7 @@ impl<'a> Str<'a> { // smartstring will keep strings smaller than 23 bytes directly in the value rather // than allocating on the heap. It's cheap to clone and will not create unnecessary // atomic writes memory traffic. - if s.len() <= 23 { + if cfg!(feature = "smartstring") && s.len() <= 23 { InnerStr::Owned(s.into()) } else { InnerStr::Arc(Arc::from(s))