summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-05-11 11:35:45 +0200
committerLaurenz <laurmaedje@gmail.com>2023-05-11 11:35:45 +0200
commit998a3c44fd79eac92c375ec9e755288bc146a279 (patch)
tree70825f2d68ed64c32b8b2551dcf0e545753f643c /src
parent2f0b5eeae09bd880e4552bb83e44d9cd32571c58 (diff)
Remove tracing from cheap functions
Turns out that having tracing enabled on some functions that get called a lot distorts the traces so that their parent stack frames look much more expensive than they actually are.
Diffstat (limited to 'src')
-rw-r--r--src/model/content.rs7
-rw-r--r--src/model/styles.rs6
-rw-r--r--src/syntax/source.rs2
-rw-r--r--src/util/mod.rs1
4 files changed, 2 insertions, 14 deletions
diff --git a/src/model/content.rs b/src/model/content.rs
index 1bd19f14..4eeecbd6 100644
--- a/src/model/content.rs
+++ b/src/model/content.rs
@@ -39,19 +39,16 @@ enum Attr {
impl Content {
/// Create an empty element.
- #[tracing::instrument()]
pub fn new(func: ElemFunc) -> Self {
Self { func, attrs: EcoVec::new() }
}
/// Create empty content.
- #[tracing::instrument()]
pub fn empty() -> Self {
Self::new(SequenceElem::func())
}
/// Create a new sequence element from multiples elements.
- #[tracing::instrument(skip_all)]
pub fn sequence(iter: impl IntoIterator<Item = Self>) -> Self {
let mut iter = iter.into_iter();
let Some(first) = iter.next() else { return Self::empty() };
@@ -94,7 +91,6 @@ impl Content {
}
/// Access the child and styles.
- #[tracing::instrument(skip_all)]
pub fn to_styled(&self) -> Option<(&Content, &Styles)> {
if !self.is::<StyledElem>() {
return None;
@@ -120,7 +116,6 @@ impl Content {
/// Cast to a trait object if the contained element has the given
/// capability.
- #[tracing::instrument(skip_all)]
pub fn with<C>(&self) -> Option<&C>
where
C: ?Sized + 'static,
@@ -132,7 +127,6 @@ impl Content {
/// Cast to a mutable trait object if the contained element has the given
/// capability.
- #[tracing::instrument(skip_all)]
pub fn with_mut<C>(&mut self) -> Option<&mut C>
where
C: ?Sized + 'static,
@@ -180,7 +174,6 @@ impl Content {
}
/// Access a field on the content.
- #[tracing::instrument(skip_all)]
pub fn field(&self, name: &str) -> Option<Value> {
if let (Some(iter), "children") = (self.to_sequence(), name) {
Some(Value::Array(iter.cloned().map(Value::Content).collect()))
diff --git a/src/model/styles.rs b/src/model/styles.rs
index efbdb9d1..54784307 100644
--- a/src/model/styles.rs
+++ b/src/model/styles.rs
@@ -563,7 +563,6 @@ impl<'a> StyleChain<'a> {
/// The resulting style chain contains styles from `local` as well as
/// `self`. The ones from `local` take precedence over the ones from
/// `self`. For folded properties `local` contributes the inner value.
- #[tracing::instrument(skip_all)]
pub fn chain<'b>(&'b self, local: &'b Styles) -> StyleChain<'b> {
if local.is_empty() {
*self
@@ -573,7 +572,6 @@ impl<'a> StyleChain<'a> {
}
/// Cast the first value for the given property in the chain.
- #[tracing::instrument(skip_all)]
pub fn get<T: Cast>(
self,
func: ElemFunc,
@@ -587,7 +585,6 @@ impl<'a> StyleChain<'a> {
}
/// Cast the first value for the given property in the chain.
- #[tracing::instrument(skip_all)]
pub fn get_resolve<T: Cast + Resolve>(
self,
func: ElemFunc,
@@ -599,7 +596,6 @@ impl<'a> StyleChain<'a> {
}
/// Cast the first value for the given property in the chain.
- #[tracing::instrument(skip_all)]
pub fn get_fold<T: Cast + Fold>(
self,
func: ElemFunc,
@@ -621,7 +617,6 @@ impl<'a> StyleChain<'a> {
}
/// Cast the first value for the given property in the chain.
- #[tracing::instrument(skip_all)]
pub fn get_resolve_fold<T>(
self,
func: ElemFunc,
@@ -656,7 +651,6 @@ impl<'a> StyleChain<'a> {
}
/// Iterate over all values for the given property in the chain.
- #[tracing::instrument(skip_all)]
pub fn properties<T: Cast + 'a>(
self,
func: ElemFunc,
diff --git a/src/syntax/source.rs b/src/syntax/source.rs
index b325cf9e..f67ed656 100644
--- a/src/syntax/source.rs
+++ b/src/syntax/source.rs
@@ -109,6 +109,7 @@ impl Source {
/// Returns the range in the new source that was ultimately reparsed.
///
/// The method panics if the `replace` range is out of bounds.
+ #[track_caller]
pub fn edit(&mut self, replace: Range<usize>, with: &str) -> Range<usize> {
let start_byte = replace.start;
let start_utf16 = self.byte_to_utf16(replace.start).unwrap();
@@ -158,6 +159,7 @@ impl Source {
/// Map a span that points into this source file to a byte range.
///
/// Panics if the span does not point into this source file.
+ #[track_caller]
pub fn range(&self, span: Span) -> Range<usize> {
self.find(span)
.expect("span does not point into this source file")
diff --git a/src/util/mod.rs b/src/util/mod.rs
index 83ec5961..f96fa55e 100644
--- a/src/util/mod.rs
+++ b/src/util/mod.rs
@@ -34,7 +34,6 @@ where
}
/// Calculate a 128-bit siphash of a value.
-#[tracing::instrument(skip_all)]
pub fn hash128<T: Hash + ?Sized>(value: &T) -> u128 {
let mut state = SipHasher13::new();
value.hash(&mut state);