mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 11:50:44 +00:00
Merge pull request #70234 from Adirio/Adirio-patch-1
Map allocation optimization for client-go/tools/cache
This commit is contained in:
commit
12cf545195
@ -179,7 +179,7 @@ func (c *ExpirationCache) Delete(obj interface{}) error {
|
|||||||
func (c *ExpirationCache) Replace(list []interface{}, resourceVersion string) error {
|
func (c *ExpirationCache) Replace(list []interface{}, resourceVersion string) error {
|
||||||
c.expirationLock.Lock()
|
c.expirationLock.Lock()
|
||||||
defer c.expirationLock.Unlock()
|
defer c.expirationLock.Unlock()
|
||||||
items := map[string]interface{}{}
|
items := make(map[string]interface{}, len(list))
|
||||||
ts := c.clock.Now()
|
ts := c.clock.Now()
|
||||||
for _, item := range list {
|
for _, item := range list {
|
||||||
key, err := c.keyFunc(item)
|
key, err := c.keyFunc(item)
|
||||||
|
@ -297,7 +297,7 @@ func (f *FIFO) Pop(process PopProcessFunc) (interface{}, error) {
|
|||||||
// after calling this function. f's queue is reset, too; upon return, it
|
// after calling this function. f's queue is reset, too; upon return, it
|
||||||
// will contain the items in the map, in no particular order.
|
// will contain the items in the map, in no particular order.
|
||||||
func (f *FIFO) Replace(list []interface{}, resourceVersion string) error {
|
func (f *FIFO) Replace(list []interface{}, resourceVersion string) error {
|
||||||
items := map[string]interface{}{}
|
items := make(map[string]interface{}, len(list))
|
||||||
for _, item := range list {
|
for _, item := range list {
|
||||||
key, err := f.keyFunc(item)
|
key, err := f.keyFunc(item)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -210,7 +210,7 @@ func (c *cache) GetByKey(key string) (item interface{}, exists bool, err error)
|
|||||||
// 'c' takes ownership of the list, you should not reference the list again
|
// 'c' takes ownership of the list, you should not reference the list again
|
||||||
// after calling this function.
|
// after calling this function.
|
||||||
func (c *cache) Replace(list []interface{}, resourceVersion string) error {
|
func (c *cache) Replace(list []interface{}, resourceVersion string) error {
|
||||||
items := map[string]interface{}{}
|
items := make(map[string]interface{}, len(list))
|
||||||
for _, item := range list {
|
for _, item := range list {
|
||||||
key, err := c.keyFunc(item)
|
key, err := c.keyFunc(item)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user