if_required_and_missing#hash?

On Thursday, March 27, 2014, Ben Hamill <notifications@github.com> wrote:

> In lib/assembler/parameter.rb:
>
> > +module Assembler
> > +  class Parameter
> > +    attr_reader :name
> > +
> > +    def initialize(name, options = {})
> > +      @name         = name.to_sym
> > +      @options      = options
> > +    end
> > +
> > +    def name_and_aliases
> > +      @name_and_aliases ||= [name] + aliases.map(&:to_sym)
> > +    end
> > +
> > +    def value_from(options, &if_required_and_missing)
> > +      @memoized_value_from ||= {}
> > +      memoization_key = [options, if_required_and_missing]
>
> Oh fuck. I just realized: This is going to keep the blocks around forever,
> now... which means that everything in scope when the block was created will
> also be in scope forever. Depending on usage, this could be a big and
> hard-to-track down memory leak.
>
> I'm not sure what the 'right' thing is... Maybe we only memoize on options,
> like you had, but we still do block calling, regardless of whether we're
> hitting the memoized value or not? Or maybe we're over-thinking and we
> don't memoize this because the speed cost is honestly likely to be pretty
> small? Bleeeeeeeeeeh.
>
> --
> Reply to this email directly or view it on GitHub<https://github.com/benhamill/assembler/pull/13/files#r11047868>
> .
>