From 0b2a5f4fbfe32cd70b1bc88b1ffbf5c67694acd3 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Sat, 23 Sep 2023 21:17:58 -0400 Subject: [PATCH] Change all runtime asserts in private functions to debug_assert. These functions aren't exposed to the public so we can confidently say that if they work in dev then they will work in production. Removing these asserts theoretically should result in a speedup. --- src/compare/sexp.rs | 4 ++-- src/parser/org_source.rs | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/compare/sexp.rs b/src/compare/sexp.rs index d06bbf0a..0cd558ec 100644 --- a/src/compare/sexp.rs +++ b/src/compare/sexp.rs @@ -106,8 +106,8 @@ fn is_slice_of(parent: &str, child: &str) -> bool { } /// Get a slice of the string that was consumed in a parser using the original input to the parser and the remaining input after the parser. -pub fn get_consumed<'s>(input: &'s str, remaining: &'s str) -> &'s str { - assert!(is_slice_of(input, remaining)); +fn get_consumed<'s>(input: &'s str, remaining: &'s str) -> &'s str { + debug_assert!(is_slice_of(input, remaining)); let source = { let offset = remaining.as_ptr() as usize - input.as_ptr() as usize; &input[..offset] diff --git a/src/parser/org_source.rs b/src/parser/org_source.rs index f38b85da..9f8c0f65 100644 --- a/src/parser/org_source.rs +++ b/src/parser/org_source.rs @@ -72,8 +72,8 @@ impl<'s> OrgSource<'s> { } pub(crate) fn get_until(&self, other: OrgSource<'s>) -> OrgSource<'s> { - assert!(other.start >= self.start); - assert!(other.end <= self.end); + debug_assert!(other.start >= self.start); + debug_assert!(other.end <= self.end); self.slice(..(other.start - self.start)) }