// cloneBindVariables returns a shallow-copy of the given bindVariables map.
508909
func cloneBindVariables(bindVariables map[string]*querypb.BindVariable) map[string]*querypb.BindVariable {
	result := make(map[string]*querypb.BindVariable)
	for key, value := range bindVariables {
		result[key] = value
	}
	return result
}
235885
func BindNamed(bindType int, query string, arg interface{}) (string, []interface{}, error) {
	return bindNamedMapper(bindType, query, arg, mapper())
}
544596
func (s *Statement) Bindings() []string {
	var bs []string
	for k := range s.BindingsMap() {
		bs = append(bs, k)
	}
	return bs
}
1363267
func normalizeBind(addr, bind string) (string, error) {
	if addr == "" {
		return bind, nil
	}
	return parseSingleIPTemplate(addr)
}
752861
func ValueBinder(f func(value string, typ reflect.Type) reflect.Value) func(*Params, string, reflect.Type) reflect.Value {
	return func(params *Params, name string, typ reflect.Type) reflect.Value {
		vals, ok := params.Values[name]
		if !ok || len(vals) == 0 {
			return reflect.Zero(typ)
		}
		return f(vals[0], typ)
	}
}
456026
func FetchBindVar(name string, bindVariables map[string]*querypb.BindVariable) (val *querypb.BindVariable, isList bool, err error) {
	name = name[1:]
	if name[0] == ':' {
		name = name[1:]
		isList = true
	}
	supplied, ok := bindVariables[name]
	if !ok {
		return nil, false, fmt.Errorf("missing bind var %s", name)
	}

	if isList {
		if supplied.Type != querypb.Type_TUPLE {
			return nil, false, fmt.Errorf("unexpected list arg type (%v) for key %s", supplied.Type, name)
		}
		if len(supplied.Values) == 0 {
			return nil, false, fmt.Errorf("empty list supplied for %s", name)
		}
		return supplied, true, nil
	}

	if supplied.Type == querypb.Type_TUPLE {
		return nil, false, fmt.Errorf("unexpected arg type (TUPLE) for non-list key %s", name)
	}

	return supplied, false, nil
}
1207452
func (s *Environment) SetVariables(v map[string]*string) *Environment {
	s.Variables = v
	return s
}
407368
func (as ContainerCPUAssignments) Clone() ContainerCPUAssignments {
	ret := make(ContainerCPUAssignments)
	for key, val := range as {
		ret[key] = val
	}
	return ret
}
1284117
func cloneAttrs(m map[string]interface{}) map[string]interface{} {
	other := make(map[string]interface{}, len(m))
	for k, v := range m {
		other[k] = v
	}
	return other
}
893646
func copyParams(src url.Values) url.Values {
	dest := url.Values{}
	for k, v := range src {
		dest[k] = v
	}
	return dest
}
58020
func (p *Namespaces) Clone() *Namespaces {
	if !p.Safe {
		p.mu.RLock()
		defer p.mu.RUnlock()
	}
	p2 := Namespaces{
		prefixes: make(map[string]string, len(p.prefixes)),
	}
	for pref, ns := range p.prefixes {
		p2.prefixes[pref] = ns
	}
	return &p2
}
1097682
func (p *CopyPropagator) plugBindings(pctx *plugContext, x interface{}) bool {

	// Kill single term expressions that are in the binding list. They will be
	// re-added during post-processing if needed.
	if expr, ok := x.(*ast.Expr); ok {
		if term, ok := expr.Terms.(*ast.Term); ok {
			if v, ok := term.Value.(ast.Var); ok {
				if root, ok := pctx.uf.Find(v); ok {
					if _, ok := pctx.bindings[root.key]; ok {
						return false
					}
				}
			}
		}
	}

	ast.WalkTerms(x, func(t *ast.Term) bool {
		// Apply union-find to remove redundant variables from input.
		switch v := t.Value.(type) {
		case ast.Var:
			if root, ok := pctx.uf.Find(v); ok {
				t.Value = root.Value()
			}
		case ast.Ref:
			if root, ok := pctx.uf.Find(v[0].Value.(ast.Var)); ok {
				v[0].Value = root.Value()
			}
		}
		// Apply binding list to substitute remaining vars.
		switch v := t.Value.(type) {
		case ast.Var:
			if b, ok := pctx.bindings[v]; ok {
				if !pctx.negated || b.v.IsGround() {
					t.Value = b.v
				}
				return true
			}
		case ast.Ref:
			// Refs require special handling. If the head of the ref was killed, then the
			// rest of the ref must be concatenated with the new base.
			//
			// Invariant: ref heads can only be replaced by refs (not calls).
			if b, ok := pctx.bindings[v[0].Value.(ast.Var)]; ok {
				if !pctx.negated || b.v.IsGround() {
					t.Value = b.v.(ast.Ref).Concat(v[1:])
				}
			}
			for i := 1; i < len(v); i++ {
				p.plugBindings(pctx, v[i])
			}
			return true
		}
		return false
	})

	return true
}
1131762
func (s *RemoteApplication) Bindings() map[string]string {
	result := make(map[string]string)
	for epName, spName := range s.doc.Bindings {
		result[epName] = spName
	}
	return result
}
281050
func cloneNodes(ns []*html.Node) []*html.Node {
	cns := make([]*html.Node, 0, len(ns))

	for _, n := range ns {
		cns = append(cns, cloneNode(n))
	}

	return cns
}
819136
func (c *Config) GetVariables() map[string]string {
	n := map[string]string{}
	for k, v := range c.variables {
		n[k] = v
	}
	return n
}
1202412
func bindValues(keyvals []interface{}) {
	for i := 1; i < len(keyvals); i += 2 {
		if v, ok := keyvals[i].(Valuer); ok {
			keyvals[i] = v()
		}
	}
}
658451
func (v *Values) Clone() *Values {
	v.lock.RLock()
	defer v.lock.RUnlock()

	return newValues(v.root)
}