// MergeReferencedArgs merges referenced args from another BuildArgs
// object into the current one
331140
func (b *BuildArgs) MergeReferencedArgs(other *BuildArgs) {
	for k := range other.referencedArgs {
		b.referencedArgs[k] = struct{}{}
	}
}
427859
func (mo *MergeOperatorStringAppend) FullMerge(key, existingValue []byte,
	operands [][]byte) ([]byte, bool) {
	mo.m.Lock()
	mo.numFull++
	mo.m.Unlock()

	s := string(existingValue)
	for _, operand := range operands {
		s = s + mo.Sep + string(operand)
	}
	return []byte(s), true
}
230345
func (hlm *hardlinkManager) Merge() ([]Resource, error) {
	var resources []Resource
	for key, linked := range hlm.hardlinks {
		if len(linked) < 1 {
			return nil, fmt.Errorf("no hardlink entrys for dev, inode pair: %#v", key)
		}

		merged, err := Merge(linked...)
		if err != nil {
			return nil, fmt.Errorf("error merging hardlink: %v", err)
		}

		resources = append(resources, merged)
	}

	return resources, nil
}
1112159
func mergeMaps(map1, map2 map[interface{}]interface{}) map[interface{}]interface{} {
	result := make(map[interface{}]interface{})
	for k, v2 := range map2 {
		if v1, ok := map1[k]; !ok {
			result[k] = v2
		} else {
			map1Inner, ok1 := v1.(map[interface{}]interface{})
			map2Inner, ok2 := v2.(map[interface{}]interface{})
			if ok1 && ok2 {
				result[k] = mergeMaps(map1Inner, map2Inner)
			} else {
				result[k] = v2
			}
		}
	}
	for k, v := range map1 {
		if v2, ok := map2[k]; !ok {
			result[k] = v
		} else {
			map1Inner, ok1 := v.(map[interface{}]interface{})
			map2Inner, ok2 := v2.(map[interface{}]interface{})
			if ok1 && ok2 {
				result[k] = mergeMaps(map1Inner, map2Inner)
			}
		}
	}
	return result
}
1247154
func (e *DefaultEffector) MergeEffects(expr string, effects []Effect, results []float64) (bool, error) {
	result := false
	if expr == "some(where (p_eft == allow))" {
		result = false
		for _, eft := range effects {
			if eft == Allow {
				result = true
				break
			}
		}
	} else if expr == "!some(where (p_eft == deny))" {
		result = true
		for _, eft := range effects {
			if eft == Deny {
				result = false
				break
			}
		}
	} else if expr == "some(where (p_eft == allow)) && !some(where (p_eft == deny))" {
		result = false
		for _, eft := range effects {
			if eft == Allow {
				result = true
			} else if eft == Deny {
				result = false
				break
			}
		}
	} else if expr == "priority(p_eft) || deny" {
		result = false
		for _, eft := range effects {
			if eft != Indeterminate {
				if eft == Allow {
					result = true
				} else {
					result = false
				}
				break
			}
		}
	} else {
		return false, errors.New("unsupported effect")
	}

	return result, nil
}
559350
func (v *Result) mergeErrors(otherResult *Result) {
	v.errors = append(v.errors, otherResult.Errors()...)
	v.score += otherResult.score
}
1037425
func WrapArguments(args ...interface{}) []reflect.Value {
	funcArgs := []reflect.Value{}

	for _, arg := range args {
		value, wrapped := arg.(reflect.Value)

		if wrapped {
			funcArgs = append(funcArgs, value)
			continue
		}

		funcArgs = append(funcArgs, reflect.ValueOf(arg))
	}

	return funcArgs
}
514550
func mergeUnfreshRoutes(before, after RoutableEndpoints, domains models.DomainSet) RoutableEndpoints {
	merged := after.copy()
	merged.Domain = before.Domain

	if !domains.Contains(before.Domain) {
		// non-fresh domain, append routes from older endpoint
		for _, oldRoute := range before.Routes {
			routeExistInNewLRP := func() bool {
				for _, newRoute := range after.Routes {
					if newRoute == oldRoute {
						return true
					}
				}
				return false
			}
			if !routeExistInNewLRP() {
				merged.Routes = append(merged.Routes, oldRoute)
			}
		}
	}

	return merged
}
135550
func MergeMultierrorWarnings(warnings ...error) string {
	var warningMsg multierror.Error
	for _, warn := range warnings {
		if warn != nil {
			multierror.Append(&warningMsg, warn)
		}
	}

	if len(warningMsg.Errors) == 0 {
		return ""
	}

	// Set the formatter
	warningMsg.ErrorFormat = warningsFormatter
	return warningMsg.Error()
}
1277163
func Merge(w io.Writer, opts *BuilderOpts, itrs []Iterator, f MergeFunc) error {
	builder, err := New(w, opts)
	if err != nil {
		return err
	}

	itr, err := NewMergeIterator(itrs, f)
	for err == nil {
		k, v := itr.Current()
		err = builder.Insert(k, v)
		if err != nil {
			return err
		}
		err = itr.Next()
	}

	if err != nil && err != ErrIteratorDone {
		return err
	}

	err = itr.Close()
	if err != nil {
		return err
	}

	err = builder.Close()
	if err != nil {
		return err
	}

	return nil
}
1258565
func (cr *ConflictResolver) addRecreateOpsToUnmergedChains(ctx context.Context,
	recreateOps []*createOp, unmergedChains, mergedChains *crChains,
	mergedPaths map[data.BlockPointer]data.Path) ([]data.Path, error) {
	if len(recreateOps) == 0 {
		return nil, nil
	}

	// First create a lookup table that maps every block pointer in
	// every merged path to a corresponding key in the mergedPaths map.
	keys := make(map[data.BlockPointer]data.BlockPointer)
	for ptr, p := range mergedPaths {
		for _, node := range p.Path {
			keys[node.BlockPointer] = ptr
		}
	}

	var newUnmergedPaths []data.Path
	for _, rop := range recreateOps {
		// If rop.Dir.Unref is a merged most recent pointer, look up the
		// original.  Otherwise rop.Dir.Unref is the original.  Use the
		// original to look up the appropriate unmerged chain and stick
		// this op at the front.
		origTargetPtr, err :=
			mergedChains.originalFromMostRecentOrSame(rop.Dir.Unref)
		if err != nil {
			return nil, err
		}

		chain, ok := unmergedChains.byOriginal[origTargetPtr]
		if !ok {
			return nil, fmt.Errorf("recreateOp for %v has no chain",
				origTargetPtr)
		}
		if len(chain.ops) == 0 {
			newUnmergedPaths = append(newUnmergedPaths, rop.getFinalPath())
		}
		chain.ops = append([]op{rop}, chain.ops...)

		// Look up the corresponding unmerged most recent pointer, and
		// check whether there's a merged path for it yet.  If not,
		// create one by looking it up in the lookup table (created
		// above) and taking the appropriate subpath.
		_, ok = mergedPaths[chain.mostRecent]
		if !ok {
			mergedMostRecent := chain.original
			if !mergedChains.isDeleted(chain.original) {
				if mChain, ok := mergedChains.byOriginal[chain.original]; ok {
					mergedMostRecent = mChain.mostRecent
				}
			}
			key, ok := keys[mergedMostRecent]
			if !ok {
				return nil, fmt.Errorf("Couldn't find a merged path "+
					"containing the target of a recreate op: %v",
					mergedMostRecent)
			}
			currPath := mergedPaths[key]
			for currPath.TailPointer() != mergedMostRecent &&
				currPath.HasValidParent() {
				currPath = *currPath.ParentPath()
			}
			mergedPaths[chain.mostRecent] = currPath
		}
	}

	return newUnmergedPaths, nil
}
1284670
func MergeTolerations(first []api.Toleration, second []api.Toleration) []api.Toleration {
	var mergedTolerations []api.Toleration
	mergedTolerations = append(mergedTolerations, second...)

	firstMap := ConvertTolerationToAMap(first)
	secondMap := ConvertTolerationToAMap(second)

	for k1, v1 := range firstMap {
		if _, ok := secondMap[k1]; !ok {
			mergedTolerations = append(mergedTolerations, v1)
		}
	}
	return mergedTolerations
}
9283
func NewUpdateRegistrationArgs(scopeURL string) *UpdateRegistrationArgs {
	args := new(UpdateRegistrationArgs)
	args.ScopeURL = scopeURL
	return args
}
1157212
func ConfigRegs(ctx types.Context) <-chan gofig.ConfigRegistration {
	c := make(chan gofig.ConfigRegistration)
	go func() {
		cfgRegsRWL.RLock()
		defer cfgRegsRWL.RUnlock()
		for _, cr := range cfgRegs {
			r := NewConfigReg(cr.name)
			cr.creg(ctx, r)
			c <- r
		}
		close(c)
	}()
	return c
}
1262758
func MergeEnvironment(current, newValues map[string]string) map[string]string {
	if current == nil {
		current = make(map[string]string)
	}
	if runtime.GOOS == "windows" {
		return mergeEnvWin(current, newValues)
	}
	return mergeEnvUnix(current, newValues)
}
754977
func (c *Command) mergePersistentFlags() {
	c.updateParentsPflags()
	c.Flags().AddFlagSet(c.PersistentFlags())
	c.Flags().AddFlagSet(c.parentsPflags)
}
1320533
func NewMergeIterator(itrs []Iterator, f MergeFunc) (*MergeIterator, error) {
	rv := &MergeIterator{
		itrs:    itrs,
		f:       f,
		currKs:  make([][]byte, len(itrs)),
		currVs:  make([]uint64, len(itrs)),
		lowIdxs: make([]int, 0, len(itrs)),
		mergeV:  make([]uint64, 0, len(itrs)),
	}
	rv.init()
	if rv.lowK == nil {
		return rv, ErrIteratorDone
	}
	return rv, nil
}