Code Review Stack Exchange is a question and answer site for peer programmer code reviews. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I optimize this for memory?

  def from_template(template, name, uid = nil)
    template.dup.tap do |new|
      new.template               = template
      new.tenant                 = tenant
      new.program_constraint     = updated_program_constraint(template)
    end
  end

  def updated_program_constraint(template)
    new_template = template.program_constraint.try(:dup)
    new_template.valid_date_times[0]['end'] = 1.year.since(tenant.get_tz.now) if new_template.valid_date_times[0]['end'].past?
    new_template
  end
share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.