// Merge another set of hooks into the existing object. Existing
// hooks will be overridden if the corresponding hooks from the
// source struct are defined. Returns true if some content was
// overiden in the process.
169896
func (h *hooks) CopyFrom(source hooks) (overridden bool) {
	overrideIfFromNotEmpty := func(from string, to *string) {
		if from != "" {
			overridden = overridden || *to != ""
			*to = from
		}
	}
	overrideIfFromNotEmpty(source.RawPreBuild, &h.RawPreBuild)
	overrideIfFromNotEmpty(source.RawPostBuild, &h.RawPostBuild)
	overrideIfFromNotEmpty(source.RawPreStart, &h.RawPreStart)
	overrideIfFromNotEmpty(source.RawPostStart, &h.RawPostStart)
	overrideIfFromNotEmpty(source.RawPreStop, &h.RawPreStop)
	overrideIfFromNotEmpty(source.RawPostStop, &h.RawPostStop)
	return
}
927765
func (s Set) Merge(set Set) {
	for t, v := range set {
		if v {
			s[t] = true
		}
	}
}
1055491
func (e PrimitiveElement) Merge(v Strategy) (Result, error) {
	return v.MergePrimitive(e)
}
1324957
func (hooks LevelHooks) Add(hook Hook) {
	for _, level := range hook.Levels() {
		hooks[level] = append(hooks[level], hook)
	}
}
432406
func (c *Context) Flush() error {
	logger.Tracef("flushing from hook context to state")
	// TODO(natefinch): make this a noop and move this code into set.

	if len(c.updates) > 0 {
		var updates []payload.Payload
		for _, pl := range c.updates {
			updates = append(updates, pl)
		}

		res, err := c.api.Track(updates...)
		if err != nil {
			return errors.Trace(err)
		}
		if len(res) > 0 && res[0].Error != nil {
			return errors.Trace(res[0].Error)
		}

		for k, v := range c.updates {
			c.payloads[k] = v
		}
		c.updates = map[string]payload.Payload{}
	}
	return nil
}
1323800
func (mi *mergeInfo) merge(dst, src pointer) {
	if dst.isNil() {
		panic("proto: nil destination")
	}
	if src.isNil() {
		return // Nothing to do.
	}

	if atomic.LoadInt32(&mi.initialized) == 0 {
		mi.computeMergeInfo()
	}

	for _, fi := range mi.fields {
		sfp := src.offset(fi.field)

		// As an optimization, we can avoid the merge function call cost
		// if we know for sure that the source will have no effect
		// by checking if it is the zero value.
		if unsafeAllowed {
			if fi.isPointer && sfp.getPointer().isNil() { // Could be slice or string
				continue
			}
			if fi.basicWidth > 0 {
				switch {
				case fi.basicWidth == 1 && !*sfp.toBool():
					continue
				case fi.basicWidth == 4 && *sfp.toUint32() == 0:
					continue
				case fi.basicWidth == 8 && *sfp.toUint64() == 0:
					continue
				}
			}
		}

		dfp := dst.offset(fi.field)
		fi.merge(dfp, sfp)
	}

	// TODO: Make this faster?
	out := dst.asPointerTo(mi.typ).Elem()
	in := src.asPointerTo(mi.typ).Elem()
	if emIn, err := extendable(in.Addr().Interface()); err == nil {
		emOut, _ := extendable(out.Addr().Interface())
		mIn, muIn := emIn.extensionsRead()
		if mIn != nil {
			mOut := emOut.extensionsWrite()
			muIn.Lock()
			mergeExtension(mOut, mIn)
			muIn.Unlock()
		}
	}

	if mi.unrecognized.IsValid() {
		if b := *src.offset(mi.unrecognized).toBytes(); len(b) > 0 {
			*dst.offset(mi.unrecognized).toBytes() = append([]byte(nil), b...)
		}
	}
}
41879
func (r *Result) Merge(others ...*Result) *Result {
	for _, other := range others {
		if other == nil {
			continue
		}
		r.mergeWithoutRootSchemata(other)
		r.rootObjectSchemata.Append(other.rootObjectSchemata)
	}
	return r
}
658282
func (b *BoolValue) Merge(onto *bool) {
	if b.v != nil {
		*onto = *(b.v)
	}
}
912176
func (a *ClientConfig) Merge(b *ClientConfig) *ClientConfig {
	result := *a

	if b.Enabled {
		result.Enabled = true
	}
	if b.StateDir != "" {
		result.StateDir = b.StateDir
	}
	if b.AllocDir != "" {
		result.AllocDir = b.AllocDir
	}
	if b.NodeClass != "" {
		result.NodeClass = b.NodeClass
	}
	if b.NetworkInterface != "" {
		result.NetworkInterface = b.NetworkInterface
	}
	if b.NetworkSpeed != 0 {
		result.NetworkSpeed = b.NetworkSpeed
	}
	if b.CpuCompute != 0 {
		result.CpuCompute = b.CpuCompute
	}
	if b.MemoryMB != 0 {
		result.MemoryMB = b.MemoryMB
	}
	if b.MaxKillTimeout != "" {
		result.MaxKillTimeout = b.MaxKillTimeout
	}
	if b.ClientMaxPort != 0 {
		result.ClientMaxPort = b.ClientMaxPort
	}
	if b.ClientMinPort != 0 {
		result.ClientMinPort = b.ClientMinPort
	}
	if result.Reserved == nil && b.Reserved != nil {
		reserved := *b.Reserved
		result.Reserved = &reserved
	} else if b.Reserved != nil {
		result.Reserved = result.Reserved.Merge(b.Reserved)
	}
	if b.GCInterval != 0 {
		result.GCInterval = b.GCInterval
	}
	if b.GCParallelDestroys != 0 {
		result.GCParallelDestroys = b.GCParallelDestroys
	}
	if b.GCDiskUsageThreshold != 0 {
		result.GCDiskUsageThreshold = b.GCDiskUsageThreshold
	}
	if b.GCInodeUsageThreshold != 0 {
		result.GCInodeUsageThreshold = b.GCInodeUsageThreshold
	}
	if b.GCMaxAllocs != 0 {
		result.GCMaxAllocs = b.GCMaxAllocs
	}
	// NoHostUUID defaults to true, merge if false
	if b.NoHostUUID != nil {
		result.NoHostUUID = b.NoHostUUID
	}

	// Add the servers
	result.Servers = append(result.Servers, b.Servers...)

	// Add the options map values
	if result.Options == nil {
		result.Options = make(map[string]string)
	}
	for k, v := range b.Options {
		result.Options[k] = v
	}

	// Add the meta map values
	if result.Meta == nil {
		result.Meta = make(map[string]string)
	}
	for k, v := range b.Meta {
		result.Meta[k] = v
	}

	// Add the chroot_env map values
	if result.ChrootEnv == nil {
		result.ChrootEnv = make(map[string]string)
	}
	for k, v := range b.ChrootEnv {
		result.ChrootEnv[k] = v
	}

	if b.ServerJoin != nil {
		result.ServerJoin = result.ServerJoin.Merge(b.ServerJoin)
	}

	return &result
}
1356605
func (c *Context) Merge(data Data) Data {
	if data == nil {
		return dupeMaps(c.data)
	} else {
		return dupeMaps(c.data, data)
	}
}
179468
func (ss *SearchStatus) Merge(other *SearchStatus) {
	ss.Total += other.Total
	ss.Failed += other.Failed
	ss.Successful += other.Successful
	if len(other.Errors) > 0 {
		if ss.Errors == nil {
			ss.Errors = make(map[string]error)
		}
		for otherIndex, otherError := range other.Errors {
			ss.Errors[otherIndex] = otherError
		}
	}
}
285268
func (merger *MatchMerger) merge(block1, block2 *BlockSpan, blockSize int64) {
	var a, b *BlockSpan = block1, block2

	if block1.StartBlock > block2.StartBlock {
		a, b = block2, block1
	}

	if isBordering(a, b, blockSize) {
		// bordering, merge
		// A ------ A B ------ B > A ---------------- A
		merger.startEndBlockMap.Delete(BlockSpanKey(a.EndBlock))
		merger.startEndBlockMap.Delete(BlockSpanKey(b.StartBlock))
		a.EndBlock = b.EndBlock

		merger.startEndBlockMap.ReplaceOrInsert(BlockSpanStart(*a))
		merger.startEndBlockMap.ReplaceOrInsert(BlockSpanEnd(*a))
	}
}
1117584
func (h HLL) Merge(g HLL) error {
	if len(h) != len(g) {
		return errors.New("size mismatch")
	}
	hDense := h[0]&(1<<6) != 0
	gDense := g[0]&(1<<6) != 0
	if hDense && gDense {
		Dense(h[8:]).Merge(Dense(g[8:]))
		h[0] |= 1 << 7 // Mark as dirty.
		return nil
	}
	if !hDense && !gDense {
		if mergeIntoSparse(sparse(h), sparse(g)) == ok {
			return nil
		}
		toDense(sparse(h))
		mergeIntoDense(Dense(h[8:]), sparse(g))
		h[0] = 128 + 64
		return nil
	}
	if hDense { // !g.Dense
		mergeIntoDense(Dense(h[8:]), sparse(g))
		h[0] |= 128
		return nil
	}
	// h is sparse, g is Dense
	toDense(sparse(h))
	Dense(h[8:]).Merge(Dense(g[8:]))
	return nil
}
655593
func (a *SentinelConfig) Merge(b *SentinelConfig) *SentinelConfig {
	result := *a
	if len(b.Imports) > 0 {
		result.Imports = append(result.Imports, b.Imports...)
	}
	return &result
}
881579
func (e MapElement) Merge(v Strategy) (Result, error) {
	return v.MergeMap(e)
}
683620
func (c ConfigPolicyNode) Merge(n ctree.Node) ctree.Node {
	// Because Add only allows the ConfigPolicyNode type we
	// are safe to convert ctree.Node interface to ConfigPolicyNode
	cd := n.(*ConfigPolicyNode)
	// For the rules in the passed ConfigPolicyNode(converted) add each rule to
	// this ConfigPolicyNode overwriting where needed.
	no := NewPolicyNode()
	for _, r := range c.rules {
		no.Add(r)
	}

	for _, r := range cd.rules {

		no.Add(r)
	}
	// Return modified version of ConfigPolicyNode(as ctree.Node)
	return no
}
799112
func (entry *Entry) Merge(merge *Entry) {
	for name, value := range merge.fields {
		entry.SetField(name, value)
	}
}