MCPcopy
hub / github.com/tinygo-org/tinygo / Cap

Method Cap

src/internal/reflectlite/value.go:815–826  ·  view source on GitHub ↗

Cap returns the capacity of this value for arrays, channels and slices. For other types, it panics.

()

Source from the content-addressed store, hash-verified

813// Cap returns the capacity of this value for arrays, channels and slices.
814// For other types, it panics.
815func (v Value) Cap() int {
816 switch v.typecode.Kind() {
817 case Array:
818 return v.typecode.Len()
819 case Chan:
820 return chancap(v.pointer())
821 case Slice:
822 return int((*sliceHeader)(v.value).cap)
823 default:
824 panic(&ValueError{Method: "Cap", Kind: v.Kind()})
825 }
826}
827
828//go:linkname mapclear runtime.hashmapClear
829func mapclear(p unsafe.Pointer)

Callers 4

showValueFunction · 0.80
TestGrowFunction · 0.80
TestTinySliceFunction · 0.80
TestClearSliceFunction · 0.80

Implementers 12

refMapcgo/sync.go
ADCsrc/machine/machine.go
pwmGroupsrc/machine/machine_rp2_pwm.go
RingBuffersrc/machine/buffer.go
RingBuffersrc/machine/usb/adc/midi/buffer.go
RingBuffersrc/machine/usb/hid/buffer.go
Register8src/runtime/volatile/register.go
Register16src/runtime/volatile/register.go
Register32src/runtime/volatile/register.go
Register64src/runtime/volatile/register.go
BitRegistersrc/runtime/volatile/bitband_nxpmk66f1
Poolsrc/sync/pool.go

Calls 5

pointerMethod · 0.95
KindMethod · 0.95
chancapFunction · 0.85
KindMethod · 0.65
LenMethod · 0.65

Tested by 3

TestGrowFunction · 0.64
TestTinySliceFunction · 0.64
TestClearSliceFunction · 0.64