diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-07 17:25:31 -0800 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2011-12-07 17:25:31 -0800 |
commit | 76c29a64b940ca82c7a15de5598f5340046b9cca (patch) | |
tree | fcab5dcc6aa8b00d3f5b2b3fe4a991d37d7cf035 | |
parent | 7e176a6d1248ac0a2a54c8f35846366040fda91b (diff) | |
download | rails-76c29a64b940ca82c7a15de5598f5340046b9cca.tar.gz rails-76c29a64b940ca82c7a15de5598f5340046b9cca.tar.bz2 rails-76c29a64b940ca82c7a15de5598f5340046b9cca.zip |
Use a hash to look up column definitions
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index a802868c01..85ad4a39a1 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -66,6 +66,7 @@ module ActiveRecord def initialize(base) @columns = [] + @columns_hash = {} @base = base end @@ -86,8 +87,7 @@ module ActiveRecord # Returns a ColumnDefinition for the column with name +name+. def [](name) - name = name.to_s - @columns.find { |column| column.name == name } + @columns_hash[name.to_s] end # Instantiates a new column for the table. @@ -283,6 +283,7 @@ module ActiveRecord def new_column_definition(base, name, type) definition = ColumnDefinition.new base, name, type @columns << definition + @columns_hash[name] = definition definition end |