Skip to content
This repository
Browse code

refactor PostgreSQLAdapter#result_as_array to create fewer Range objects

  • Loading branch information...
commit c9710a43ff6cdc536f08983b007768ae6a66dd10 1 parent 7c4e040
Aaron Patterson authored July 12, 2010
6  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -431,15 +431,15 @@ def insert(sql, name = nil, pk = nil, id_value = nil, sequence_name = nil)
431 431
       def result_as_array(res) #:nodoc:
432 432
         # check if we have any binary column and if they need escaping
433 433
         unescape_col = []
434  
-        for j in 0...res.nfields do
  434
+        res.nfields.times do |j|
435 435
           # unescape string passed BYTEA field (OID == 17)
436 436
           unescape_col << ( res.ftype(j)==17 )
437 437
         end
438 438
 
439 439
         ary = []
440  
-        for i in 0...res.ntuples do
  440
+        res.ntuples.times do |i|
441 441
           ary << []
442  
-          for j in 0...res.nfields do
  442
+          res.nfields.times do |j|
443 443
             data = res.getvalue(i,j)
444 444
             data = unescape_bytea(data) if unescape_col[j] and data.is_a?(String)
445 445
             ary[i] << data

0 notes on commit c9710a4

Please sign in to comment.
Something went wrong with that request. Please try again.