func cellsFromC()

in h3.go [1362:1381]


func cellsFromC(chs []C.H3Index, prune, refit bool) []Cell {
	in := unsafe.Slice((*Cell)(unsafe.Pointer(&chs[0])), len(chs))
	out := in[:0]
	for i := range in {
		if prune && in[i] <= 0 {
			continue
		}
		out = append(out, in[i])
	}
	if refit {
		// Some algorithms require a maximum sized array, but only use a subset
		// of the memory.  refit sizes the slice to the last non-empty element.
		for i := len(out) - 1; i >= 0; i-- {
			if out[i] == 0 {
				out = out[:i]
			}
		}
	}
	return out
}