Skip to content

Commit

Permalink
syntax: add 'Properties::memory_usage'
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
BurntSushi committed Apr 15, 2023
1 parent 2f02150 commit 8d1d9b1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions regex-syntax/src/hir/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2080,6 +2080,13 @@ impl Properties {
self.0.alternation_literal
}

/// Returns the total amount of heap memory usage, in bytes, used by this
/// `Properties` value.
#[inline]
pub fn memory_usage(&self) -> usize {
core::mem::size_of::<PropertiesI>()
}

/// Returns a new set of properties that corresponds to the union of the
/// iterator of properties given.
///
Expand Down

0 comments on commit 8d1d9b1

Please sign in to comment.