You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: decode_slice.go
    path of file: ./repos/plumber/vendor/github.com/batchcorp/thrift-iterator/binding/reflection
    
    the code of the file until where you have to start completion: package reflection

import (
	"unsafe"
	"github.com/batchcorp/thrift-iterator/spi"
	"reflect"
)

type sliceDecoder struct {
	sliceType   reflect.Type
	elemType    reflect.Type
	elem
    
func (decoder *sliceDecoder) decode(ptr unsafe.Pointer, iter spi.Iterator) {
	slice := (*sliceHeader)(ptr)
	slice.Len = 0
	offset := uintptr(0)
	_, length := iter.ReadListHeader()

	if slice.Cap < length {
		newVal := reflect.MakeSlice(decoder.sliceType, 0, length)
		slice.Data = unsafe.Pointer(newVal.Pointer())
		slice.Cap = length
	}

	for i := 0; i < length; i++ {
		decoder.elemDecoder.decode(unsafe.Pointer(uintptr(slice.Data)+offset), iter)
		offset += decoder.elemType.Size()
		slice.Len += 1
	}
}