Skip to content

Commit

Permalink
use set replace map (istio#45473)
Browse files Browse the repository at this point in the history
  • Loading branch information
rokkiter authored Jun 15, 2023
1 parent 737a52d commit 1f91b25
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pilot/pkg/model/sidecar.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ type SidecarScope struct {
// Set of known configs this sidecar depends on.
// This field will be used to determine the config/resource scope
// which means which config changes will affect the proxies within this scope.
configDependencies map[ConfigHash]struct{}
configDependencies sets.Set[ConfigHash]

// The namespace to treat as the administrative root namespace for
// Istio configuration.
Expand Down Expand Up @@ -191,7 +191,7 @@ func DefaultSidecarScopeForNamespace(ps *PushContext, configNamespace string) *S
destinationRules: make(map[host.Name][]*ConsolidatedDestRule),
destinationRulesByNames: make(map[types.NamespacedName]*config.Config),
servicesByHostname: make(map[host.Name]*Service, len(defaultEgressListener.services)),
configDependencies: make(map[ConfigHash]struct{}),
configDependencies: make(sets.Set[ConfigHash]),
RootNamespace: ps.Mesh.RootNamespace,
Version: ps.PushVersion,
}
Expand Down Expand Up @@ -264,7 +264,7 @@ func ConvertToSidecarScope(ps *PushContext, sidecarConfig *config.Config, config
Name: sidecarConfig.Name,
Namespace: configNamespace,
Sidecar: sidecar,
configDependencies: make(map[ConfigHash]struct{}),
configDependencies: make(sets.Set[ConfigHash]),
RootNamespace: ps.Mesh.RootNamespace,
Version: ps.PushVersion,
}
Expand Down Expand Up @@ -545,8 +545,7 @@ func (sc *SidecarScope) DependsOnConfig(config ConfigKey) bool {
return true
}

_, exists := sc.configDependencies[config.HashCode()]
return exists
return sc.configDependencies.Contains(config.HashCode())
}

func (sc *SidecarScope) GetService(hostname host.Name) *Service {
Expand All @@ -563,11 +562,9 @@ func (sc *SidecarScope) AddConfigDependencies(dependencies ...ConfigHash) {
return
}
if sc.configDependencies == nil {
sc.configDependencies = make(map[ConfigHash]struct{})
}

for _, config := range dependencies {
sc.configDependencies[config] = struct{}{}
sc.configDependencies = sets.New(dependencies...)
} else {
sc.configDependencies.InsertAll(dependencies...)
}
}

Expand Down

0 comments on commit 1f91b25

Please sign in to comment.