diff options
author | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-26 20:02:27 -0300 |
---|---|---|
committer | Rafael Mendonça França <rafaelmfranca@gmail.com> | 2014-03-26 20:02:27 -0300 |
commit | 4e2ca9b23fcaa98f4ef375a3a6d8eee579baec94 (patch) | |
tree | cdb7988e0bf635ee0a54aa982b14b1600e8470e5 /activerecord/lib/active_record | |
parent | fb743941d51475e416f4b4d1ecd8b3a91e501cad (diff) | |
download | rails-4e2ca9b23fcaa98f4ef375a3a6d8eee579baec94.tar.gz rails-4e2ca9b23fcaa98f4ef375a3a6d8eee579baec94.tar.bz2 rails-4e2ca9b23fcaa98f4ef375a3a6d8eee579baec94.zip |
Improve the method
* cache `o.name` value
* Avoid extra `concat` call
* Avoid extra `<<` call
Diffstat (limited to 'activerecord/lib/active_record')
-rw-r--r-- | activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb index a1748c9261..35931d864f 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract_mysql_adapter.rb @@ -7,11 +7,12 @@ module ActiveRecord class SchemaCreation < AbstractAdapter::SchemaCreation def visit_TableDefinition(o) - create_sql = "CREATE#{' TEMPORARY' if o.temporary} TABLE " - create_sql << "#{quote_table_name(o.name)} " - statements = [] - statements.concat(o.columns.map { |c| accept c }) - statements.concat(o.indexes.map { |(column_name, options)| index_in_create(o.name, column_name, options) }) + name = o.name + create_sql = "CREATE#{' TEMPORARY' if o.temporary} TABLE #{quote_table_name(name)} " + + statements = o.columns.map { |c| accept c } + statements.concat(o.indexes.map { |column_name, options| index_in_create(name, column_name, options) }) + create_sql << "(#{statements.join(', ')}) " if statements.present? create_sql << "#{o.options}" create_sql << " AS #{@conn.to_sql(o.as)}" if o.as |