Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 2 of 2 for SliceCapWithSize (0.71 sec)

  1. src/internal/saferio/io.go

    	}
    	return buf, nil
    }
    
    // SliceCapWithSize returns the capacity to use when allocating a slice.
    // After the slice is allocated with the capacity, it should be
    // built using append. This will avoid allocating too much memory
    // if the capacity is large and incorrect.
    //
    // A negative result means that the value is always too big.
    func SliceCapWithSize(size, c uint64) int {
    	if int64(c) < 0 || c != uint64(int(c)) {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Aug 31 00:34:05 UTC 2023
    - 3.4K bytes
    - Viewed (0)
  2. src/encoding/gob/decode.go

    		// of interfaces, there will be buffer reloads.
    		errorf("%s slice too big: %d elements of %d bytes", typ.Elem(), u, size)
    	}
    	if value.Cap() < n {
    		safe := saferio.SliceCapWithSize(size, uint64(n))
    		if safe < 0 {
    			errorf("%s slice too big: %d elements of %d bytes", typ.Elem(), u, size)
    		}
    		value.Set(reflect.MakeSlice(typ, safe, safe))
    	} else {
    		value.SetLen(n)
    	}
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu Sep 07 19:10:23 UTC 2023
    - 40.1K bytes
    - Viewed (0)
Back to top