mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 17:30:00 +00:00
Switch to index rather than copy indexing.
This was 17% of all allocations on a recent profile.
This commit is contained in:
parent
29e8b6123f
commit
beda3fd92d
@ -234,8 +234,8 @@ func (r *Requirement) String() string {
|
|||||||
// Add adds requirements to the selector. It copies the current selector returning a new one
|
// Add adds requirements to the selector. It copies the current selector returning a new one
|
||||||
func (lsel internalSelector) Add(reqs ...Requirement) Selector {
|
func (lsel internalSelector) Add(reqs ...Requirement) Selector {
|
||||||
var sel internalSelector
|
var sel internalSelector
|
||||||
for _, item := range lsel {
|
for ix := range lsel {
|
||||||
sel = append(sel, item)
|
sel = append(sel, lsel[ix])
|
||||||
}
|
}
|
||||||
for _, r := range reqs {
|
for _, r := range reqs {
|
||||||
sel = append(sel, r)
|
sel = append(sel, r)
|
||||||
@ -248,8 +248,8 @@ func (lsel internalSelector) Add(reqs ...Requirement) Selector {
|
|||||||
// its Requirements match the input Labels. If any
|
// its Requirements match the input Labels. If any
|
||||||
// Requirement does not match, false is returned.
|
// Requirement does not match, false is returned.
|
||||||
func (lsel internalSelector) Matches(l Labels) bool {
|
func (lsel internalSelector) Matches(l Labels) bool {
|
||||||
for _, req := range lsel {
|
for ix := range lsel {
|
||||||
if matches := req.Matches(l); !matches {
|
if matches := lsel[ix].Matches(l); !matches {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -260,8 +260,8 @@ func (lsel internalSelector) Matches(l Labels) bool {
|
|||||||
// the internalSelector Requirements' human-readable strings.
|
// the internalSelector Requirements' human-readable strings.
|
||||||
func (lsel internalSelector) String() string {
|
func (lsel internalSelector) String() string {
|
||||||
var reqs []string
|
var reqs []string
|
||||||
for _, req := range lsel {
|
for ix := range lsel {
|
||||||
reqs = append(reqs, req.String())
|
reqs = append(reqs, lsel[ix].String())
|
||||||
}
|
}
|
||||||
return strings.Join(reqs, ",")
|
return strings.Join(reqs, ",")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user