// Mainly coppied over from mergeAuthorizationMaps
341572
func mergeDigitalWalletAuthorizationMap(newAuths []DigitalWalletAuthorization, oldAuths []DigitalWalletAuthorization) []DigitalWalletAuthorization {
OLDAUTHS:
	for _, oldAuth := range oldAuths {
		// check all new auths to make sure it isn't overwritten
		for _, newAuth := range newAuths {
			// overwritten, continue with the next oldAuth
			if oldAuth.RequestedLabel == newAuth.RequestedLabel {
				continue OLDAUTHS
			}
		}
		// All new auths checked and no match, so lets append it
		newAuths = append(newAuths, oldAuth)
	}

	return newAuths
}
1172509
func RegistedSortedAPIMap() []apiConfig {
	results := []apiConfig{}

	keys := []string{}
	for key := range registedAPICallerMap {
		keys = append(keys, key)
	}
	sort.Strings(keys)
	for _, key := range keys {
		apiconf := registedAPICallerMap[key]
		results = append(results, apiconf)
	}

	return results
}
618279
func (sa *StorageAuthority) GetAuthorizations(ctx context.Context, req *sapb.GetAuthorizationsRequest) (*sapb.Authorizations, error) {
	return &sapb.Authorizations{}, nil
}
1116585
func (v mergeStrategy) MergeMap(e apply.MapElement) (apply.Result, error) {
	// No merge logic if adding or deleting a field
	if result, done := v.doAddOrDelete(e); done {
		return result, nil
	}
	// Detect conflict in MapElement
	if err := v.doConflictDetect(e); err != nil {
		return apply.Result{}, err
	}
	return v.doMergeMap(e.GetValues())
}
774119
func (lsa *LeadershipSettingsAccessor) Merge(bulkArgs params.MergeLeadershipSettingsBulkParams) (params.ErrorResults, error) {

	requireAppName, err := lsa.callerApplication()
	if err != nil {
		return params.ErrorResults{}, err
	}
	// Start out assuming the caller is a unit (for older clients).
	callerUnitId := lsa.authorizer.GetAuthTag().Id()

	results := make([]params.ErrorResult, len(bulkArgs.Params))

	for i, arg := range bulkArgs.Params {
		result := &results[i]

		// TODO(fwereade): we shoudn't assume a ApplicationTag: we should
		// use an actual auth func to determine permissions.
		applicationTag, err := names.ParseApplicationTag(arg.ApplicationTag)
		if err != nil {
			result.Error = common.ServerError(err)
			continue
		}

		// If a unit is passed in as an arg, use that instead of the caller id.
		if arg.UnitTag != "" {
			unitTag, err := names.ParseUnitTag(arg.UnitTag)
			if err != nil {
				result.Error = common.ServerError(err)
				continue
			}
			callerUnitId = unitTag.Id()
			unitAppName, err := names.UnitApplication(callerUnitId)
			if err != nil || unitAppName != requireAppName {
				result.Error = common.ServerError(common.ErrPerm)
				continue
			}
		}

		appName := applicationTag.Id()
		if appName != requireAppName {
			result.Error = common.ServerError(common.ErrPerm)
			continue
		}

		token := lsa.leaderCheckFn(appName, callerUnitId)
		err = lsa.mergeSettingsChunkFn(token, appName, arg.Settings)
		if err != nil {
			result.Error = common.ServerError(err)
		}
	}

	return params.ErrorResults{Results: results}, 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
}
461360
func Merge(mapA map[string]interface{}, mapB map[string]interface{}) map[string]interface{} {
	for k, v := range mapA {
		mapB[k] = v
	}

	return mapB
}
618836
func mergePoloniexDepthUpdates(target, source poloniexOrders) {
	for bin, pt := range source {
		if pt.volume == 0 {
			delete(source, bin)
			delete(target, bin)
			continue
		}
		target[bin] = pt
	}
}
736459
func mergePAX(hdr *Header, paxHdrs map[string]string) (err error) {
	for k, v := range paxHdrs {
		if v == "" {
			continue // Keep the original USTAR value
		}
		var id64 int64
		switch k {
		case paxPath:
			hdr.Name = v
		case paxLinkpath:
			hdr.Linkname = v
		case paxUname:
			hdr.Uname = v
		case paxGname:
			hdr.Gname = v
		case paxUid:
			id64, err = strconv.ParseInt(v, 10, 64)
			hdr.Uid = int(id64) // Integer overflow possible
		case paxGid:
			id64, err = strconv.ParseInt(v, 10, 64)
			hdr.Gid = int(id64) // Integer overflow possible
		case paxAtime:
			hdr.AccessTime, err = parsePAXTime(v)
		case paxMtime:
			hdr.ModTime, err = parsePAXTime(v)
		case paxCtime:
			hdr.ChangeTime, err = parsePAXTime(v)
		case paxSize:
			hdr.Size, err = strconv.ParseInt(v, 10, 64)
		default:
			if strings.HasPrefix(k, paxSchilyXattr) {
				if hdr.Xattrs == nil {
					hdr.Xattrs = make(map[string]string)
				}
				hdr.Xattrs[k[len(paxSchilyXattr):]] = v
			}
		}
		if err != nil {
			return ErrHeader
		}
	}
	hdr.PAXRecords = paxHdrs
	return nil
}
1300245
func (auth *Authorization) Merge(a *Authorization) {
	// Merge all but the grantedTo and username fields, those are already the same
	// Do some sanity checking anyway
	if auth.Username != a.Username || auth.GrantedTo != a.GrantedTo {
		return
	}

	// Bool fields are merged on a once given is alwasy given basis
	auth.Facebook = auth.Facebook || a.Facebook
	auth.Github = auth.Github || a.Github
	auth.Name = auth.Name || a.Name
	auth.KeyStore = auth.KeyStore || a.KeyStore
	auth.See = auth.See || a.See

	// Authorized organizations can simply be expanded
	auth.Organizations = append(auth.Organizations, a.Organizations...)

	// Ownerof is an abstraction over a []string, can also be expanded
	auth.OwnerOf.EmailAddresses = append(auth.OwnerOf.EmailAddresses, a.OwnerOf.EmailAddresses...)

	// DigitalWallet is a separate type
	auth.DigitalWallet = mergeDigitalWalletAuthorizationMap(auth.DigitalWallet, a.DigitalWallet)

	// Merge the authorization maps
	auth.Addresses = mergeAuthorizationMaps(auth.Addresses, a.Addresses)
	auth.Avatars = mergeAuthorizationMaps(auth.Avatars, a.Avatars)
	auth.BankAccounts = mergeAuthorizationMaps(auth.BankAccounts, a.BankAccounts)
	auth.EmailAddresses = mergeAuthorizationMaps(auth.EmailAddresses, a.EmailAddresses)
	auth.Phonenumbers = mergeAuthorizationMaps(auth.Phonenumbers, a.Phonenumbers)
	auth.PublicKeys = mergeAuthorizationMaps(auth.PublicKeys, a.PublicKeys)
	auth.ValidatedEmailAddresses = mergeAuthorizationMaps(auth.ValidatedEmailAddresses, a.ValidatedEmailAddresses)
	auth.ValidatedPhonenumbers = mergeAuthorizationMaps(auth.ValidatedPhonenumbers, a.ValidatedPhonenumbers)
}
1066759
func (lsa *LeadershipSettingsAccessor) Merge(appId, unitId string, settings map[string]string) error {

	if err := lsa.checkAPIVersion("Merge"); err != nil {
		return errors.Annotatef(err, "cannot access leadership api")
	}
	results, err := lsa.bulkMerge(lsa.prepareMerge(appId, unitId, settings))
	if err != nil {
		return errors.Annotatef(err, "failed to call leadership api")
	}
	if count := len(results.Results); count != 1 {
		return errors.Errorf("expected 1 result from leadership api, got %d", count)
	}
	if results.Results[0].Error != nil {
		return errors.Annotatef(results.Results[0].Error, "failed to merge leadership settings")
	}
	return nil
}
192864
func (p *PullRequest) GetAuthorAssociation() string {
	if p == nil || p.AuthorAssociation == nil {
		return ""
	}
	return *p.AuthorAssociation
}
654722
func (s *AuthorizationService) CreateAuthorization(ctx context.Context, authorization *platform.Authorization) error {
	return s.CreateAuthorizationFn(ctx, authorization)
}
1283802
func (s *AuthorizationService) FindAuthorizations(ctx context.Context, filter platform.AuthorizationFilter, opt ...platform.FindOptions) (as []*platform.Authorization, i int, err error) {
	defer func() {
		if err != nil {
			s.Logger.Info("error finding authorizations", zap.Error(err))
		}
	}()

	return s.AuthorizationService.FindAuthorizations(ctx, filter, opt...)
}
692714
func MergePullRequestAction(actUser *User, repo *Repository, pull *Issue) error {
	return mergePullRequestAction(x, actUser, repo, pull)
}
533138
func (f *Field) mergeRemoteAvailableShards(b *roaring.Bitmap) {
	f.mu.Lock()
	defer f.mu.Unlock()
	f.remoteAvailableShards = f.remoteAvailableShards.Union(b)
}
191590
func (sa *StorageAuthority) FinalizeAuthorization(_ context.Context, authz core.Authorization) (err error) {
	return
}