// PrefixFromArgs is used when doing a prefix scan for an object.
965760
func (*PreparedQueryIndex) PrefixFromArgs(args ...interface{}) ([]byte, error) {
	if len(args) != 1 {
		return nil, fmt.Errorf("must provide only a single argument")
	}
	arg, ok := args[0].(string)
	if !ok {
		return nil, fmt.Errorf("argument must be a string: %#v", args[0])
	}
	arg = "\x00" + strings.ToLower(arg)
	return []byte(arg), 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)
}
1334038
func PrefixKey(handler cfg.Handler, prefix string) cfg.Handler {
	return Apply(func(key string) (string, error) { return fmt.Sprintf("%s%s", prefix, key), nil }, nil, handler)
}
1259395
func prefixLen(a, b []byte) int {
	var i, length = 0, len(a)
	if len(b) < length {
		length = len(b)
	}
	for ; i < length; i++ {
		if a[i] != b[i] {
			break
		}
	}
	return i
}
135355
func (pb *Bar) Prefix(prefix string) *Bar {
	pb.mu.Lock()
	defer pb.mu.Unlock()

	pb.prefix = prefix
	return pb
}
1046043
func (r *Request) Prefix(segments ...string) *Request {
	if r.err != nil {
		return r
	}
	r.pathPrefix = path.Join(r.pathPrefix, path.Join(segments...))
	return r
}
496
func (e *EnumDescriptor) prefix() string {
	typeName := e.alias()
	if e.parent == nil {
		// If the enum is not part of a message, the prefix is just the type name.
		return CamelCase(typeName[len(typeName)-1]) + "_"
	}
	return CamelCaseSlice(typeName[0:len(typeName)-1]) + "_"
}
1130514
func DeletePrefix(prefix string) error {
	err := Client().DeletePrefix(prefix)
	Trace("DeletePrefix", err, logrus.Fields{fieldPrefix: prefix})
	return err
}
1075015
func prefix(prefixLen int, s string) string {
	if len(s) > prefixLen {
		return s[:prefixLen]
	}
	return s
}
1238967
func (d DoubleArray) PrefixSearch(input string) (id int, ok bool) {
	var p, q, i int
	bufLen := len(d)
	for size := len(input); i < size; i++ {
		if input[i] == terminator {
			return
		}
		p = q
		q = int(d[p].Base) + int(input[i])
		if q >= bufLen || int(d[q].Check) != p {
			break
		}
		ahead := int(d[q].Base) + int(terminator)
		if ahead < bufLen && int(d[ahead].Check) == q && int(d[ahead].Base) <= 0 {
			id = int(-d[ahead].Base)
			ok = true
		}
	}
	return
}
1120048
func (b *Branch) prefixMembers(branchPrefix []byte, searchPrefix []byte) (members []*MemberInfo) {
	exists, br, matchedPrefix := b.hasPrefixBranch(searchPrefix)
	if exists {
		members = br.members(matchedPrefix)
	}
	return
}
1123060
func prefixToSegment(p Prefix) Reg {
	switch p &^ PrefixImplicit {
	case PrefixCS:
		return CS
	case PrefixDS:
		return DS
	case PrefixES:
		return ES
	case PrefixFS:
		return FS
	case PrefixGS:
		return GS
	case PrefixSS:
		return SS
	}
	return 0
}
405435
func (c *config) determinePrefix(prefixFlag string) {
	// CLI takes precedence over config
	if len(prefixFlag) > 0 {
		c.prefix = prefixFlag
		return
	}
	// If prefix is not configured, it is equal to prefix: true
	if c.RawPrefix == nil {
		c.RawPrefix = true
	}
	// Use configured prefix:
	// true -> folder name
	// false -> no prefix
	// string -> use as-is
	switch concretePrefix := c.RawPrefix.(type) {
	case bool:
		if concretePrefix {
			c.prefix = filepath.Base(c.path) + "_"
		} else {
			c.prefix = ""
		}
	case string:
		c.prefix = expandEnv(concretePrefix)
	default:
		panic(StatusError{fmt.Errorf("prefix must be either string or boolean, got %s", c.RawPrefix), 65})
	}
}
493357
func prefixFromUserAgent(u string) string {
	m := strings.Split(u, "/")[0]
	buf := bytes.NewBuffer(nil)
	for _, r := range m {
		// Ignore non-printable characters
		if !unicode.IsPrint(r) {
			continue
		}
		// Only append if we have room for it
		if buf.Len()+utf8.RuneLen(r) > validation.FieldManagerMaxLength {
			break
		}
		buf.WriteRune(r)
	}
	return buf.String()
}
1087222
func (l *LockerOptions) Prefix() string {
	prefix := l.prefix
	if !strings.HasPrefix(prefix, "/") {
		prefix = "/" + prefix
	}

	if prefix == "" {
		return DefaultPrefix
	} else {
		return prefix
	}
}
1291369
func (c *Client) prefix() (string, error) {
	if err := c.prefixOnce.Do(c.initPrefix); err != nil {
		return "", err
	}
	return c.prefixv, nil
}
117416
func (t *NotificationConfig) AddFilterPrefix(prefix string) {
	if t.Filter == nil {
		t.Filter = &Filter{}
	}
	newFilterRule := FilterRule{Name: "prefix", Value: prefix}
	// Replace any prefix rule if existing and add to the list otherwise
	for index := range t.Filter.S3Key.FilterRules {
		if t.Filter.S3Key.FilterRules[index].Name == "prefix" {
			t.Filter.S3Key.FilterRules[index] = newFilterRule
			return
		}
	}
	t.Filter.S3Key.FilterRules = append(t.Filter.S3Key.FilterRules, newFilterRule)
}