[HN Gopher] Show HN: A LRU cache using go generics
       ___________________________________________________________________
        
       Show HN: A LRU cache using go generics
        
       Author : _256
       Score  : 49 points
       Date   : 2022-01-12 13:13 UTC (1 days ago)
        
 (HTM) web link (github.com)
 (TXT) w3m dump (github.com)
        
       | morelisp wrote:
       | > Feedback is welcome
       | 
       | You'll probably be a lot better off a) preallocating the elements
       | so your memory is nicely contiguous, b) tracking indices and not
       | pointers. If I wanted to pay 24b overhead per item I'd use an
       | `interface{}`. :)
        
         | olliej wrote:
         | Which pointer are you wanting to replace, there are a few and I
         | can't work out which would be best replaced with an int :) (not
         | the author, and not a go developer, just reading through the
         | code and couldn't work out which you were talking about :) )
         | 
         | Similar for what you want to preallocate.
        
           | [deleted]
        
           | morelisp wrote:
           | Preallocate the map and the entry ({V, next, prev}) objects.
           | Replace next and prev and the map value with indices.
        
       | _256 wrote:
       | This is a simple LRU cache I made to get my hands on generics
       | which is available in the go 1.18 beta. Feedback is welcome :-)
        
         | [deleted]
        
         | bogomipz wrote:
         | Might you or anyone else have any good links or references that
         | helped you come up to speed on generics in Go?
        
           | meling wrote:
           | The tutorial from the Go team is pretty good to learn the
           | basics: https://go.dev/doc/tutorial/generics
        
       ___________________________________________________________________
       (page generated 2022-01-13 23:01 UTC)