Skip to content

Optimize class method all #15

@matiasgarcia

Description

@matiasgarcia

Class method all, located at https://github.com/bitex-la/static_models/blob/master/lib/static_models.rb#L113-L115 does this:

      def all
        values.values
      end

values is a Hash object.

Hash#values (https://ruby-doc.org/core-3.1.0/Hash.html#method-i-values) Returns a new Array containing all values in self.

I think there is room for optimization here, given that other class methods such as find_by_code rely on all, and when this method is used in loops you can be instantiating the same objects over and over unintentionally.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions