Add a JumpTableData::with_capacity and use it.
As with Vec::with_capacity, this helps reduce intermediate heap allocation.
This commit is contained in:
@@ -31,6 +31,14 @@ impl JumpTableData {
|
||||
}
|
||||
}
|
||||
|
||||
/// Create a new empty jump table with the specified capacity.
|
||||
pub fn with_capacity(capacity: usize) -> JumpTableData {
|
||||
JumpTableData {
|
||||
table: Vec::with_capacity(capacity),
|
||||
holes: 0,
|
||||
}
|
||||
}
|
||||
|
||||
/// Set a table entry.
|
||||
///
|
||||
/// The table will grow as needed to fit `idx`.
|
||||
|
||||
Reference in New Issue
Block a user