Uploaded image for project: 'Mongoid'
  1. Mongoid
  2. MONGOID-4969

Improve efficiency of clone method

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 7.2.0
    • Affects Version/s: None
    • Component/s: Attributes
    • Labels:
    • Fully Compatible

      The document #clone method is currently quite inefficient and could be improved. See the provided gist and PR for reference.


      [Original description]

      We have some problems with `clone` method and `protected_attributes_continued` gem. When calls `self.class.new(attrs)` for attributes, which not included in `attr_accessible` list.

      I rewrote this code. It is not only resolved our problem, but it increases total copy execution speed:

      https://gist.github.com/vsevolod/28055a93f3ec2539f2582b2c91420990

            Assignee:
            oleg.pudeyev@mongodb.com Oleg Pudeyev (Inactive)
            Reporter:
            gsevka@gmail.com Всеволод Аврамов
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: