// Translates the array sizes to a Go-lang declaration of a (nested) array of the inner type.
// Simply returns the inner type if arraySizes is empty.
760433
func arrayBindingGo(inner string, arraySizes []string) string {
	out := ""
	//prepend all array sizes, from outer (end arraySizes) to inner (start arraySizes)
	for i := len(arraySizes) - 1; i >= 0; i-- {
		out += "[" + arraySizes[i] + "]"
	}
	out += inner
	return out
}
1124181
func (d *Decoder) DecodeArray() ([]interface{}, error) {
	if c := d.skipSpaces(); c != '[' {
		return nil, d.error(c, "looking for beginning of array")
	}
	val, err := d.array()
	if err != nil {
		return nil, err
	}
	if c := d.skipSpaces(); d.pos < d.end {
		return nil, d.error(c, "after top-level value")
	}
	return val, nil
}
528405
func ToArray(value interface{}) (values []string) {
	switch value := value.(type) {
	case []string:
		values = []string{}
		for _, v := range value {
			if v != "" {
				values = append(values, v)
			}
		}
	case []interface{}:
		for _, v := range value {
			values = append(values, fmt.Sprint(v))
		}
	default:
		if value := fmt.Sprint(value); value != "" {
			values = []string{value}
		}
	}
	return
}
17297
func (rkb TLFReaderKeyBundleV3) Size() (bytes int) {
	bytes += cache.PtrSize + rkb.Keys.Size() // Keys

	// TLFEphemeralPublicKeys
	bytes += rkb.TLFEphemeralPublicKeys.Size()

	// For codec.UnknownFieldSetHandler. It has a private map field which we
	// can't inspect unless extending the codec package. Just assume it's empty
	// for now.
	bytes += cache.PtrSize

	return bytes
}
1131304
func NewArrayTypeDef(init ...*ArrayTypeDef) *ArrayTypeDef {
	var o *ArrayTypeDef
	if len(init) == 1 {
		o = init[0]
	} else {
		o = new(ArrayTypeDef)
	}
	return o.Init()
}
849604
func (schema *Schema) arrayOfEnumValuesValue(v interface{}) *[]SchemaEnumValue {
	a := make([]SchemaEnumValue, 0)
	switch v := v.(type) {
	default:
		fmt.Printf("arrayOfEnumValuesValue: unexpected type %T\n", v)
	case []interface{}:
		for _, v2 := range v {
			switch v2 := v2.(type) {
			default:
				fmt.Printf("arrayOfEnumValuesValue: unexpected type %T\n", v2)
			case string:
				a = append(a, SchemaEnumValue{String: &v2})
			case bool:
				a = append(a, SchemaEnumValue{Bool: &v2})
			}
		}
	}
	return &a
}
613658
func parseSize(d []byte) (n int) {
	l := len(d)
	if l == 0 {
		return -1
	}
	var (
		i   int
		dec byte
	)

	// Note: Use `goto` here to avoid for loop in order
	// to have the function be inlined.
	// See: https://github.com/golang/go/issues/14768
loop:
	dec = d[i]
	if dec < asciiZero || dec > asciiNine {
		return -1
	}
	n = n*10 + (int(dec) - asciiZero)

	i++
	if i < l {
		goto loop
	}
	return n
}
1069083
func safeArrayGetElementSize(safearray *SafeArray) (length *uint32, err error) {
	l, _, err := procSafeArrayGetElemsize.Call(uintptr(unsafe.Pointer(safearray)))
	length = (*uint32)(unsafe.Pointer(l))
	return
}
857064
func sizeof(t reflect.Type, tag reflect.StructTag) int {
	switch t.Kind() {
	case reflect.Array:
		if s := sizeof(t.Elem(), tag); s >= 0 {
			return s * t.Len()
		}

	case reflect.Struct:
		if tag.Get("type") == "union" {
			max := 0
			for i, n := 0, t.NumField(); i < n; i++ {
				s := sizeof(t.Field(i).Type, t.Field(i).Tag)
				if s < 0 {
					return -1
				}
				if s > max {
					max = s
				}
			}
			return max
		} else {
			sum := 0
			for i, n := 0, t.NumField(); i < n; i++ {
				s := sizeof(t.Field(i).Type, t.Field(i).Tag)
				if s < 0 {
					return -1
				}
				sum += s
			}
			return sum
		}

	case reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64,
		reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64,
		reflect.Float32, reflect.Float64, reflect.Complex64, reflect.Complex128:
		return int(t.Size())

	case reflect.String:
		if s, err := strconv.Atoi(tag.Get("size")); err == nil && s > 0 {
			return s
		} else {
			return -1
		}
	}

	return -1
}
6666
func (g *Container) ArrayOfSize(size int, path ...string) (*Container, error) {
	a := make([]interface{}, size)
	return g.Set(a, path...)
}
382073
func (z *NestOuter) Msgsize() (s int) {
	s = 1 + 6
	if z.Inner == nil {
		s += msgp.NilSize
	} else {
		s += 1 + 6 + msgp.StringPrefixSize + len(z.Inner.Hello)
	}
	return
}
1158909
func subArrayUsage(arrayType reflect.Type, fieldName string) string {
	// Convert plural field names to singular.  Only works for English.
	singularFieldName := fieldName
	if strings.HasSuffix(fieldName, "ies") {
		singularFieldName = strings.TrimSuffix(fieldName, "ies")
		singularFieldName = singularFieldName + "y"
	} else if strings.HasSuffix(fieldName, "es") {
		singularFieldName = strings.TrimSuffix(fieldName, "es")
	} else if strings.HasSuffix(fieldName, "s") {
		singularFieldName = strings.TrimSuffix(fieldName, "s")
	}

	elemType := arrayType.Elem()
	switch elemType.Kind() {
	case reflect.String:
		return fmt.Sprintf("[%q,...]", singularFieldName)

	case reflect.Struct:
		return fmt.Sprintf("[%s,...]", subStructUsage(elemType))
	}

	// Fall back to simply showing the field name in array syntax.
	return fmt.Sprintf(`[%s,...]`, singularFieldName)
}
523933
func (t *typeName) VisitArray(a *proto.Array) {
	s := &typeName{}
	a.SubType.Accept(s)
	t.Name = fmt.Sprintf("[]%s", s.Name)
}
1340467
func interfaceToArray(input interface{}) interface{} {
	var (
		result  interface{}
		coords  []float64
		coords2 [][]float64
		coords3 [][][]float64
		coords4 [][][][]float64
	)
	switch it := input.(type) {
	case []float64, [][]float64, [][][]float64, [][][][]float64:
		result = it
	case []interface{}:
		for inx := 0; inx < len(it); inx++ {
			switch curr1 := it[inx].(type) {
			case float64:
				coords = append(coords, curr1)
				result = coords
			case []interface{}:
				switch curr2 := interfaceToArray(curr1).(type) {
				case []float64:
					coords2 = append(coords2, curr2)
					result = coords2
				case [][]float64:
					coords3 = append(coords3, curr2)
					result = coords3
				case [][][]float64:
					coords4 = append(coords4, curr2)
					result = coords4
				}
			}
		}
	}
	return result
}
1235237
func InStringArray(arr []string, el string) bool {
	for _, v := range arr {
		if v == el {
			return true
		}
	}
	return false
}
147908
func convertArray(datum interface{}) ([]interface{}, error) {
	arrayValues, ok := datum.([]interface{})
	if ok {
		return arrayValues, nil
	}
	// NOTE: When given a slice of any other type, zip values to
	// items as a convenience to client.
	v := reflect.ValueOf(datum)
	if v.Kind() != reflect.Slice {
		return nil, fmt.Errorf("cannot create []interface{}: expected slice; received: %T", datum)
	}
	// NOTE: Two better alternatives to the current algorithm are:
	//   (1) mutate the reflection tuple underneath to convert the
	//       []int, for example, to []interface{}, with O(1) complexity
	//   (2) use copy builtin to zip the data items over with O(n) complexity,
	//       but more efficient than what's below.
	// Suggestions?
	arrayValues = make([]interface{}, v.Len())
	for idx := 0; idx < v.Len(); idx++ {
		arrayValues[idx] = v.Index(idx).Interface()
	}
	return arrayValues, nil
}
646521
func ensureArray(a []interface{}, l int) []interface{} {
	if len(a) >= l {
		return a
	}
	b := make([]interface{}, l)
	copy(b, a)
	return b
}