Skip to content

Commit c517e08

Browse files
committed
syntax: add 'Properties::memory_usage'
Since it uses heap memory and because it's something you typically hang on to in a regex engine, we expose a routine for computing heap memory. We might consider doing this for other types in regex-syntax, but there hasn't been a strong need for it yet.
1 parent 28404c2 commit c517e08

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

regex-syntax/src/hir/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -2080,6 +2080,13 @@ impl Properties {
20802080
self.0.alternation_literal
20812081
}
20822082

2083+
/// Returns the total amount of heap memory usage, in bytes, used by this
2084+
/// `Properties` value.
2085+
#[inline]
2086+
pub fn memory_usage(&self) -> usize {
2087+
core::mem::size_of::<PropertiesI>()
2088+
}
2089+
20832090
/// Returns a new set of properties that corresponds to the union of the
20842091
/// iterator of properties given.
20852092
///

0 commit comments

Comments
 (0)