mirror of
https://github.com/Z3Prover/z3
synced 2025-07-26 06:07:01 +00:00
add reallocate() function and use it in bit_vector and vector containers
give a speedup of 1-4% Signed-off-by: Nuno Lopes <a-nlopes@microsoft.com>
This commit is contained in:
parent
55ca6ce44b
commit
44e647e72b
5 changed files with 51 additions and 18 deletions
|
@ -25,13 +25,11 @@ Revision History:
|
|||
#define MK_MASK(_num_bits_) ((1U << _num_bits_) - 1)
|
||||
|
||||
void bit_vector::expand_to(unsigned new_capacity) {
|
||||
unsigned * new_data = alloc_svect(unsigned, new_capacity);
|
||||
memset(new_data, 0, new_capacity * sizeof(unsigned));
|
||||
if (m_capacity > 0) {
|
||||
memcpy(new_data, m_data, m_capacity * sizeof(unsigned));
|
||||
dealloc_svect(m_data);
|
||||
if (m_data) {
|
||||
m_data = (unsigned*)memory::reallocate(m_data, new_capacity * sizeof(unsigned));
|
||||
} else {
|
||||
m_data = alloc_svect(unsigned, new_capacity);
|
||||
}
|
||||
m_data = new_data;
|
||||
m_capacity = new_capacity;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue