File tree Expand file tree Collapse file tree 1 file changed +5
-6
lines changed
Expand file tree Collapse file tree 1 file changed +5
-6
lines changed Original file line number Diff line number Diff line change @@ -61,16 +61,16 @@ func New(maxElementCount int) Cache {
6161}
6262
6363func (c * lruCache ) Add (node Node ) Node {
64- key := string ( node .GetKey () )
65- if e , exists := c .dict [key ]; exists {
64+ key := node .GetKey ()
65+ if e , exists := c .dict [string ( key ) ]; exists {
6666 c .ll .MoveToFront (e )
6767 old := e .Value
6868 e .Value = node
6969 return old .(Node )
7070 }
7171
7272 elem := c .ll .PushFront (node )
73- c .dict [key ] = elem
73+ c .dict [string ( key ) ] = elem
7474
7575 if c .ll .Len () > c .maxElementCount {
7676 oldest := c .ll .Back ()
@@ -97,9 +97,8 @@ func (c *lruCache) Len() int {
9797}
9898
9999func (c * lruCache ) Remove (key []byte ) Node {
100- keyS := string (key )
101- if elem , exists := c .dict [keyS ]; exists {
102- return c .removeWithKey (elem , keyS )
100+ if elem , exists := c .dict [string (key )]; exists {
101+ return c .removeWithKey (elem , string (key ))
103102 }
104103 return nil
105104}
You can’t perform that action at this time.
0 commit comments