mirror of
https://github.com/MariaDB/server.git
synced 2025-01-23 07:14:17 +01:00
parent
50aef9b7d9
commit
ae87b251c8
1 changed files with 10 additions and 4 deletions
|
@ -272,13 +272,19 @@ void range_buffer::append_point(const DBT *key) {
|
|||
}
|
||||
|
||||
void range_buffer::maybe_grow(size_t size) {
|
||||
static const size_t initial_size = 4096;
|
||||
static const size_t aggressive_growth_threshold = 128 * 1024;
|
||||
if (m_buf_current + size > m_buf_size) {
|
||||
const size_t needed = m_buf_current + size;
|
||||
if (m_buf_size < needed) {
|
||||
if (m_buf_size == 0) {
|
||||
m_buf_size = initial_size;
|
||||
}
|
||||
// aggressively grow the range buffer to the threshold,
|
||||
// but only additivately increase the size after that.
|
||||
if (m_buf_size < aggressive_growth_threshold) {
|
||||
m_buf_size = m_buf_size ? m_buf_size * 2 : get_initial_size(size);
|
||||
} else {
|
||||
while (m_buf_size < needed && m_buf_size < aggressive_growth_threshold) {
|
||||
m_buf_size <<= 1;
|
||||
}
|
||||
while (m_buf_size < needed) {
|
||||
m_buf_size += aggressive_growth_threshold;
|
||||
}
|
||||
XREALLOC(m_buf, m_buf_size);
|
||||
|
|
Loading…
Add table
Reference in a new issue