@@ -5,7 +5,7 @@ use std::error::Error;
5
5
use std:: fmt:: Write ;
6
6
use std:: hash:: { Hash , Hasher } ;
7
7
use std:: str:: FromStr ;
8
- use std:: { cmp, fmt, mem , str} ;
8
+ use std:: { cmp, fmt, str} ;
9
9
10
10
use crate :: header:: name:: HeaderName ;
11
11
@@ -424,27 +424,7 @@ macro_rules! from_integers {
424
424
( $( $name: ident: $t: ident => $max_len: expr) ,* ) => { $(
425
425
impl From <$t> for HeaderValue {
426
426
fn from( num: $t) -> HeaderValue {
427
- let mut buf = if mem:: size_of:: <BytesMut >( ) - 1 < $max_len {
428
- // On 32bit platforms, BytesMut max inline size
429
- // is 15 bytes, but the $max_len could be bigger.
430
- //
431
- // The likelihood of the number *actually* being
432
- // that big is very small, so only allocate
433
- // if the number needs that space.
434
- //
435
- // The largest decimal number in 15 digits:
436
- // It wold be 10.pow(15) - 1, but this is a constant
437
- // version.
438
- if num as u64 > 999_999_999_999_999_999 {
439
- BytesMut :: with_capacity( $max_len)
440
- } else {
441
- // fits inline...
442
- BytesMut :: new( )
443
- }
444
- } else {
445
- // full value fits inline, so don't allocate!
446
- BytesMut :: new( )
447
- } ;
427
+ let mut buf = BytesMut :: with_capacity( $max_len) ;
448
428
let _ = buf. write_str( :: itoa:: Buffer :: new( ) . format( num) ) ;
449
429
HeaderValue {
450
430
inner: buf. freeze( ) ,
0 commit comments