package unique
import (
)
func [ comparable]( , *cloneSeq) {
for , := range .stringOffsets {
:= (*string)(unsafe.Pointer(uintptr(unsafe.Pointer(&)) + ))
* = stringslite.Clone(*)
}
return
}
var singleStringClone = cloneSeq{stringOffsets: []uintptr{0}}
type cloneSeq struct {
stringOffsets []uintptr
}
func ( *abi.Type) cloneSeq {
if == nil {
return cloneSeq{}
}
if .Kind() == abi.String {
return singleStringClone
}
var cloneSeq
switch .Kind() {
case abi.Struct:
buildStructCloneSeq(, &, 0)
case abi.Array:
buildArrayCloneSeq(, &, 0)
}
return
}
func ( *abi.Type, *cloneSeq, uintptr) {
:= .StructType()
for := range .Fields {
:= &.Fields[]
switch .Typ.Kind() {
case abi.String:
.stringOffsets = append(.stringOffsets, +.Offset)
case abi.Struct:
(.Typ, , +.Offset)
case abi.Array:
buildArrayCloneSeq(.Typ, , +.Offset)
}
}
}
func ( *abi.Type, *cloneSeq, uintptr) {
:= .ArrayType()
:= .Elem
:=
for range .Len {
switch .Kind() {
case abi.String:
.stringOffsets = append(.stringOffsets, )
case abi.Struct:
buildStructCloneSeq(, , )
case abi.Array:
(, , )
}
+= .Size()
:= uintptr(.FieldAlign())
= ( + - 1) &^ ( - 1)
}
}