#2 ✓resolved
bahuvrihi

Can this be more efficient?

Reported by bahuvrihi | December 8th, 2008 @ 03:25 PM

Seems like the answer is yes:


  # Initializes config. Default config values
  # are overridden as specified by overrides.
  def initialize_config(overrides={})
    delegates = self.class.configurations

    # note the defaults could be stored first and overridden
    # by the overrides, but this is likely more efficient
    # on average since delegates duplicate default values.
    store = {}
    overrides.each_pair do |key, value|
      store[key] = value
    end
    delegates.each_pair do |key, delegate|
      store[key] = delegate.default unless store.has_key?(key)
    end

    @config = DelegateHash.new(delegates, store).bind(self)
  end

Comments and changes to this ticket

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Class configurations that map to the command line.

People watching this ticket

Pages