Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
1.11.3 (TBD)
============
TODO

Improvements:

* [BUG #1297](https://github.com/rust-lang/regex/issues/1297):
Improve memory usage by trimming excess memory capacity in some spots.


1.11.2 (2025-08-24)
===================
This is a new patch release of `regex` with some minor fixes. A larger number
Expand Down
4 changes: 4 additions & 0 deletions regex-automata/src/dfa/dense.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,6 +1274,10 @@ impl Builder {
}
// Look for and set the universal starting states.
dfa.set_universal_starts();
dfa.tt.table.shrink_to_fit();
dfa.st.table.shrink_to_fit();
dfa.ms.slices.shrink_to_fit();
dfa.ms.pattern_ids.shrink_to_fit();
Ok(dfa)
}

Expand Down
2 changes: 2 additions & 0 deletions regex-automata/src/dfa/onepass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,8 @@ impl<'a> InternalBuilder<'a> {
}
}
self.shuffle_states();
self.dfa.starts.shrink_to_fit();
self.dfa.table.shrink_to_fit();
Ok(self.dfa)
}

Expand Down
2 changes: 2 additions & 0 deletions regex-automata/src/dfa/sparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,8 @@ impl DFA<Vec<u8>> {
new_state.set_next_at(i, next);
}
}
new.tt.sparse.shrink_to_fit();
new.st.table.shrink_to_fit();
debug!(
"created sparse DFA, memory usage: {} (dense memory usage: {})",
new.memory_usage(),
Expand Down
2 changes: 2 additions & 0 deletions regex-automata/src/nfa/thompson/nfa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1338,6 +1338,8 @@ impl Inner {
self.look_set_prefix_any =
self.look_set_prefix_any.union(prefix_any);
}
self.states.shrink_to_fit();
self.start_pattern.shrink_to_fit();
NFA(Arc::new(self))
}

Expand Down
3 changes: 3 additions & 0 deletions regex-automata/src/util/captures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1606,6 +1606,9 @@ impl GroupInfo {
}
}
group_info.fixup_slot_ranges()?;
group_info.slot_ranges.shrink_to_fit();
group_info.name_to_index.shrink_to_fit();
group_info.index_to_name.shrink_to_fit();
Ok(GroupInfo(Arc::new(group_info)))
}

Expand Down
Loading