// longestPrefix finds the length of the shared prefix
// of two strings
359367
func longestPrefix(k1, k2 []byte) int {
	max := len(k1)
	if l := len(k2); l < max {
		max = l
	}
	var i int
	for i = 0; i < max; i++ {
		if k1[i] != k2[i] {
			break
		}
	}
	return i
}
29031
func (p Params) WithPrefix(prefix string) string {
	if len(p) == 0 {
		return ""
	}

	params := []string{}
	for i := range p {
		if prefix == "" {
			params = append(params, unexport(p[i].Name))
		} else {
			params = append(params, prefix+unexport(p[i].Name))
		}
	}
	return strings.Join(params, ", ")
}
540960
func (s *ListObjectsV2Output) SetPrefix(v string) *ListObjectsV2Output {
	s.Prefix = &v
	return s
}
194203
func (e *etcdClient) GetPrefix(ctx context.Context, prefix string) (string, []byte, error) {
	duration := spanstat.Start()
	e.limiter.Wait(ctx)
	getR, err := e.client.Get(ctx, prefix, client.WithPrefix())
	increaseMetric(prefix, metricRead, "GetPrefix", duration.EndError(err).Total(), err)
	if err != nil {
		return "", nil, Hint(err)
	}

	if getR.Count == 0 {
		return "", nil, nil
	}
	return string(getR.Kvs[0].Key), getR.Kvs[0].Value, nil
}
680690
func IteratePrefix(db DB, prefix []byte) Iterator {
	var start, end []byte
	if len(prefix) == 0 {
		start = nil
		end = nil
	} else {
		start = cp(prefix)
		end = cpIncr(prefix)
	}
	return db.Iterator(start, end)
}
1268016
func splitPrefixes(prefixes ...[]byte) ([]byte, [][]byte) {
	switch {
	case len(prefixes) == 0 || len(prefixes[0]) == 0:
		return nil, prefixes
	case len(prefixes) == 1:
		return prefixes[0], nil
	}

	var prefix []byte
	for i := 0; ; i++ {
		var cur byte
		var matched bool
		for j, prefix := range prefixes {
			switch {
			case len(prefix) <= i:
				matched = true
				break

			case j == 0:
				cur = prefix[i]
				continue

			case cur != prefix[i]:
				matched = true
				break
			}
		}

		if matched {
			break
		}

		prefix = append(prefix, cur)
	}

	next := make([][]byte, 0, len(prefixes))
	for _, remaining := range prefixes {
		next = append(next, remaining[len(prefix):])
	}
	return prefix, next
}
1305738
func (s *ResourceDataSyncS3Destination) SetPrefix(v string) *ResourceDataSyncS3Destination {
	s.Prefix = &v
	return s
}
1258987
func PrunePrefixes(prefixes []string) []string {
	prunedPrefixes := []string{}
	for i := 0; i < len(prefixes); i++ {
		foundPrefix := false
		for j := 0; j < len(prefixes); j++ {
			if i == j {
				continue
			}
			if strings.HasPrefix(prefixes[i], prefixes[j]) {
				foundPrefix = true
			}
		}
		if !foundPrefix {
			prunedPrefixes = append(prunedPrefixes, prefixes[i])
		}
	}
	return prunedPrefixes
}
845883
func AddPrefix(ctx context.Context, prefix string) context.Context {
	if prefix == "" {
		return ctx
	}
	pfx := Prefix(ctx)
	if pfx == "" {
		return WithPrefix(ctx, prefix)
	}
	return WithPrefix(ctx, pfx+prefix)
}
835288
func comparePrefix(a, b prefix) int {
	au, bu := binary.BigEndian.Uint64(a[:8]), binary.BigEndian.Uint64(b[:8])
	if au == bu {
		return 0
	} else if au < bu {
		return -1
	}
	return 1
}
1151573
func SharedPrefixLen(a, b []byte) int {
	i, n := 0, len(a)
	if n > len(b) {
		n = len(b)
	}
	for i < n && a[i] == b[i] {
		i++
	}
	return i
}
1132530
func (t *Trie) HasPrefix(prefix string) bool {
	return t.Root.hasPrefix([]byte(prefix))
}
1018351
func (s *DescribeBatchPredictionsInput) SetPrefix(v string) *DescribeBatchPredictionsInput {
	s.Prefix = &v
	return s
}
190736
func (s *ListObjectVersionsInput) SetPrefix(v string) *ListObjectVersionsInput {
	s.Prefix = &v
	return s
}
906387
func keyPrefix(key []byte) (pre prefix) {
	if len(key) >= prefixSize {
		return *(*prefix)(unsafe.Pointer(&key[0]))
	}
	copy(pre[:], key)
	return pre
}
558018
func sharedPrefixLen(a, b []byte) int {
	i := 0
	for i < len(a) && i < len(b) {
		if a[i] != b[i] {
			return i
		}
		i++
	}
	return i
}
780282
func (s *DescribeEvaluationsInput) SetPrefix(v string) *DescribeEvaluationsInput {
	s.Prefix = &v
	return s
}