Skip to content

Commit 42e751a

Browse files
committed
original_tiny_original_2x
1 parent f9e2dce commit 42e751a

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/liballoc/raw_vec.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -217,24 +217,29 @@ fn amortized_new_capacity(elem_size: usize, current_capacity: usize,
217217
let growth_capacity = match current_capacity {
218218
// Empty vector => at least 64 bytes
219219
//
220-
// [OLD]:
221-
// 0 => if elem_size > (!0) / 8 { 1 } else { 4 },
220+
// [Original]:
221+
0 => if elem_size > (!0) / 8 { 1 } else { 4 },
222222
// [NEW]:
223223
// 0 => (64 / elem_size).max(1),
224224
// [NEW 2]:
225-
0 => (32 / elem_size).max(4),
225+
// 0 => (32 / elem_size).max(4),
226226
//
227+
227228
// Small and large vectors (<= 4096 bytes, and >= 4096 * 32 bytes):
228229
//
229230
// FIXME: jemalloc specific behavior, allocators should provide a
230231
// way to query the byte size of blocks that can grow inplace.
231232
//
232233
// jemalloc can never grow in place small blocks but blocks larger
233234
// than or equal to 4096 bytes can be expanded in place:
234-
c if c < 4096 / elem_size => 2 * c,
235-
c if c > 4096 * 32 / elem_size => 2 * c,
235+
// c if c < 4096 / elem_size => 2 * c,
236+
// c if c > 4096 * 32 / elem_size => 2 * c,
237+
236238
// Medium sized vectors in the [4096, 4096 * 32) bytes range:
237-
c => c / 2 * 3
239+
// c => c / 2 * 3,
240+
241+
// [Original]
242+
c => 2 * c,
238243
};
239244
cmp::max(growth_capacity,
240245
current_capacity.checked_add(capacity_increase).unwrap())

0 commit comments

Comments
 (0)