@@ -217,24 +217,29 @@ fn amortized_new_capacity(elem_size: usize, current_capacity: usize,
217
217
let growth_capacity = match current_capacity {
218
218
// Empty vector => at least 64 bytes
219
219
//
220
- // [OLD ]:
221
- // 0 => if elem_size > (!0) / 8 { 1 } else { 4 },
220
+ // [Original ]:
221
+ 0 => if elem_size > ( !0 ) / 8 { 1 } else { 4 } ,
222
222
// [NEW]:
223
223
// 0 => (64 / elem_size).max(1),
224
224
// [NEW 2]:
225
- 0 => ( 32 / elem_size) . max ( 4 ) ,
225
+ // 0 => (32 / elem_size).max(4),
226
226
//
227
+
227
228
// Small and large vectors (<= 4096 bytes, and >= 4096 * 32 bytes):
228
229
//
229
230
// FIXME: jemalloc specific behavior, allocators should provide a
230
231
// way to query the byte size of blocks that can grow inplace.
231
232
//
232
233
// jemalloc can never grow in place small blocks but blocks larger
233
234
// 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
+
236
238
// 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,
238
243
} ;
239
244
cmp:: max ( growth_capacity,
240
245
current_capacity. checked_add ( capacity_increase) . unwrap ( ) )
0 commit comments