fn reserve_inner(&mut self, additional: usize) {
        let len = self.len();

        // Reserving involves abandoning the currently shared buffer and
        // allocating a new vector with the requested capacity.
        let new_cap = len + additional;

        unsafe {
            let inner = self.as_inner();
            let vec_cap = inner.cap - SHARED_VEC_SIZE;

            // try to reclaim the buffer. This is possible if the current
            // handle is the only outstanding handle pointing to the buffer.
            if inner.is_unique() && vec_cap >= new_cap {
                let offset = inner.offset;
                inner.offset = SHARED_VEC_SIZE as u32;

                // The capacity is sufficient, reclaim the buffer
                let src = (self.0.as_ptr() as *mut u8).add(offset as usize);
                let dst = (self.0.as_ptr() as *mut u8).add(SHARED_VEC_SIZE);
                ptr::copy(src, dst, len);
            } else {
                // Create a new vector storage
                let pool = inner.pool;
                *self = InnerVec::from_slice(new_cap, self.as_ref(), pool);
            }
        }
    }
// In separate function to allow the short-circuits in `reserve` to
// be inline-able. Significant helps performance.
In separate function to allow the short-circuits in `reserve` to
be inline-able. Significant helps performance.
In separate function to allow the short - circuits in ` reserve ` to be inline - able . Significant helps performance .
fn reserve_inner(&mut self, additional: usize) {
        let len = self.len();
        // Reserving involves abandoning the currently shared buffer and
        // allocating a new vector with the requested capacity.
        let new_cap = len + additional;
        unsafe {
            let inner = self.as_inner();
            let vec_cap = inner.cap - SHARED_VEC_SIZE;
            // try to reclaim the buffer. This is possible if the current
            // handle is the only outstanding handle pointing to the buffer.
            if inner.is_unique() && vec_cap >= new_cap {
                let offset = inner.offset;
                inner.offset = SHARED_VEC_SIZE as u32;
                // The capacity is sufficient, reclaim the buffer
                let src = (self.0.as_ptr() as *mut u8).add(offset as usize);
                let dst = (self.0.as_ptr() as *mut u8).add(SHARED_VEC_SIZE);
                ptr::copy(src, dst, len);
            } else {
                // Create a new vector storage
                let pool = inner.pool;
                *self = InnerVec::from_slice(new_cap, self.as_ref(), pool);
            }
        }
    }
fn reserve_inner ( & mut self , additional : usize ) { let len = self . len ( ) ; // Reserving involves abandoning the currently shared buffer and // allocating a new vector with the requested capacity. let new_cap = len + additional ; unsafe { let inner = self . as_inner ( ) ; let vec_cap = inner . cap - SHARED_VEC_SIZE ; // try to reclaim the buffer. This is possible if the current // handle is the only outstanding handle pointing to the buffer. if inner . is_unique ( ) && vec_cap >= new_cap { let offset = inner . offset ; inner . offset = SHARED_VEC_SIZE as u32 ; // The capacity is sufficient, reclaim the buffer let src = ( self . 0 . as_ptr ( ) as * mut u8 ) . add ( offset as usize ) ; let dst = ( self . 0 . as_ptr ( ) as * mut u8 ) . add ( SHARED_VEC_SIZE ) ; ptr :: copy ( src , dst , len ) ; } else { // Create a new vector storage let pool = inner . pool ; * self = InnerVec :: from_slice ( new_cap , self . as_ref ( ) , pool ) ; } } }
In separate function to allow the short-circuits in `reserve` to
be inline-able.
In separate function to allow the short - circuits in ` reserve ` to be inline - able .
&mut self
additional
usize
&mut self
additional
usize