unsafe fn new_uninitialized(capacity: usize) -> RawTable<K, V> {
        if capacity == 0 {
            return RawTable {
                size: 0,
                capacity_mask: capacity.wrapping_sub(1),
                hashes: TaggedHashUintPtr::new(EMPTY as *mut HashUint),
                marker: marker::PhantomData,
            };
        }

        // No need for `checked_mul` before a more restrictive check performed
        // later in this method.
        let hashes_size = capacity.wrapping_mul(size_of::<HashUint>());
        let pairs_size = capacity.wrapping_mul(size_of::<(K, V)>());

        // Allocating hashmaps is a little tricky. We need to allocate two
        // arrays, but since we know their sizes and alignments up front,
        // we just allocate a single array, and then have the subarrays
        // point into it.
        //
        // This is great in theory, but in practice getting the alignment
        // right is a little subtle. Therefore, calculating offsets has been
        // factored out into a different function.
        let (alignment, hash_offset, size, oflo) = calculate_allocation(hashes_size,
                                                                        align_of::<HashUint>(),
                                                                        pairs_size,
                                                                        align_of::<(K, V)>());
        assert!(!oflo, "capacity overflow");

        // One check for overflow that covers calculation and rounding of size.
        let size_of_bucket = size_of::<HashUint>().checked_add(size_of::<(K, V)>()).unwrap();
        assert!(size >=
                capacity.checked_mul(size_of_bucket)
                    .expect("capacity overflow"),
                "capacity overflow");

        let buffer = Heap.alloc(Layout::from_size_align(size, alignment).unwrap())
            .unwrap_or_else(|e| Heap.oom(e));

        let hashes = buffer.offset(hash_offset as isize) as *mut HashUint;

        RawTable {
            capacity_mask: capacity.wrapping_sub(1),
            size: 0,
            hashes: TaggedHashUintPtr::new(hashes),
            marker: marker::PhantomData,
        }
    }
/// Does not initialize the buckets. The caller should ensure they,
/// at the very least, set every hash to EMPTY_BUCKET.
Does not initialize the buckets. The caller should ensure they,
at the very least, set every hash to EMPTY_BUCKET.
Does not initialize the buckets . The caller should ensure they at the very least set every hash to EMPTY_BUCKET .
unsafe fn new_uninitialized(capacity: usize) -> RawTable<K, V> {
        if capacity == 0 {
            return RawTable {
                size: 0,
                capacity_mask: capacity.wrapping_sub(1),
                hashes: TaggedHashUintPtr::new(EMPTY as *mut HashUint),
                marker: marker::PhantomData,
            };
        }
        // No need for `checked_mul` before a more restrictive check performed
        // later in this method.
        let hashes_size = capacity.wrapping_mul(size_of::<HashUint>());
        let pairs_size = capacity.wrapping_mul(size_of::<(K, V)>());
        // Allocating hashmaps is a little tricky. We need to allocate two
        // arrays, but since we know their sizes and alignments up front,
        // we just allocate a single array, and then have the subarrays
        // point into it.
        //
        // This is great in theory, but in practice getting the alignment
        // right is a little subtle. Therefore, calculating offsets has been
        // factored out into a different function.
        let (alignment, hash_offset, size, oflo) = calculate_allocation(hashes_size,
                                                                        align_of::<HashUint>(),
                                                                        pairs_size,
                                                                        align_of::<(K, V)>());
        assert!(!oflo, "capacity overflow");
        // One check for overflow that covers calculation and rounding of size.
        let size_of_bucket = size_of::<HashUint>().checked_add(size_of::<(K, V)>()).unwrap();
        assert!(size >=
                capacity.checked_mul(size_of_bucket)
                    .expect("capacity overflow"),
                "capacity overflow");
        let buffer = Heap.alloc(Layout::from_size_align(size, alignment).unwrap())
            .unwrap_or_else(|e| Heap.oom(e));
        let hashes = buffer.offset(hash_offset as isize) as *mut HashUint;
        RawTable {
            capacity_mask: capacity.wrapping_sub(1),
            size: 0,
            hashes: TaggedHashUintPtr::new(hashes),
            marker: marker::PhantomData,
        }
    }
unsafe fn new_uninitialized ( capacity : usize ) -> RawTable < K , V > { if capacity == 0 { return RawTable { size : 0 , capacity_mask : capacity . wrapping_sub ( 1 ) , hashes : TaggedHashUintPtr :: new ( EMPTY as * mut HashUint ) , marker : marker :: PhantomData , } ; } // No need for `checked_mul` before a more restrictive check performed // later in this method. let hashes_size = capacity . wrapping_mul ( size_of :: < HashUint > ( ) ) ; let pairs_size = capacity . wrapping_mul ( size_of :: < ( K , V ) > ( ) ) ; // Allocating hashmaps is a little tricky. We need to allocate two // arrays, but since we know their sizes and alignments up front, // we just allocate a single array, and then have the subarrays // point into it. // // This is great in theory, but in practice getting the alignment // right is a little subtle. Therefore, calculating offsets has been // factored out into a different function. let ( alignment , hash_offset , size , oflo ) = calculate_allocation ( hashes_size , align_of :: < HashUint > ( ) , pairs_size , align_of :: < ( K , V ) > ( ) ) ; assert ! ( oflo " " ) ; // One check for overflow that covers calculation and rounding of size. let size_of_bucket = size_of :: < HashUint > ( ) . checked_add ( size_of :: < ( K , V ) > ( ) ) . unwrap ( ) ; assert ! ( size capacity checked_mul ( size_of_bucket ) expect ( " " ) " " ) ; let buffer = Heap . alloc ( Layout :: from_size_align ( size , alignment ) . unwrap ( ) ) . unwrap_or_else ( | e | Heap . oom ( e ) ) ; let hashes = buffer . offset ( hash_offset as isize ) as * mut HashUint ; RawTable { capacity_mask : capacity . wrapping_sub ( 1 ) , size : 0 , hashes : TaggedHashUintPtr :: new ( hashes ) , marker : marker :: PhantomData , } }
Does not initialize the buckets.
Does not initialize the buckets .
capacity
usize
capacity
usize