1. 04 8月, 2015 7 次提交
  2. 03 8月, 2015 18 次提交
  3. 02 8月, 2015 6 次提交
    • B
      Save a string allocation inside loop · d531edc8
      Benjamin Quorning 提交于
      In the `tag_options` method, strings are continuously added to the
      `output` string. Previously, we concatenated two strings and added the
      generated string to `output`. By adding each of the strings to
      `output`, one after the other, we will save the allocation of that
      concatenated string.
      
      Benchmark:
      
          require 'benchmark/ips'
      
          sep = " ".freeze
      
          Benchmark.ips do |x|
            x.report("string +") {
              output = ""
              output << sep + "foo"
            }
            x.report("string <<") {
              output = ""
              output << sep
              output << "foo"
            }
            x.compare!
          end
      
      Results (Ruby 2.2.2):
      
          Calculating -------------------------------------
                      string +    88.086k i/100ms
                     string <<    94.287k i/100ms
          -------------------------------------------------
                      string +      2.407M (± 5.8%) i/s -     12.068M
                     string <<      2.591M (± 7.0%) i/s -     12.917M
      
          Comparison:
                     string <<:  2591482.4 i/s
                      string +:  2406883.7 i/s - 1.08x slower
      d531edc8
    • B
      Use #start_with? and #[] for speed · 113f8a6c
      Benjamin Quorning 提交于
      While the readability may be slightly worse, the speed improvement is
      significant: Twice as fast when there's no leading "/" to remove, and
      over 4 times as fast when there is a leading "/".
      
      Benchmark:
      
          require 'benchmark/ips'
      
          def match(controller)
            if controller
              if m = controller.match(/\A\/(?<controller_without_leading_slash>.*)/)
                m[:controller_without_leading_slash]
              else
                controller
              end
            end
          end
      
          def start_with(controller)
            if controller
              if controller.start_with?('/'.freeze)
                controller[1..-1]
              else
                controller
              end
            end
          end
      
          Benchmark.ips do |x|
            x.report("match") { match("no_leading_slash") }
            x.report("start_with") { start_with("no_leading_slash") }
      
            x.compare!
          end
      
          Benchmark.ips do |x|
            x.report("match") { match("/a_leading_slash") }
            x.report("start_with") { start_with("/a_leading_slash") }
      
            x.compare!
          end
      
      Result (Ruby 2.2.2):
      
          Calculating -------------------------------------
                         match    70.324k i/100ms
                    start_with   111.264k i/100ms
          -------------------------------------------------
                         match      1.468M (± 7.1%) i/s -      7.314M
                    start_with      3.787M (± 3.5%) i/s -     18.915M
      
          Comparison:
                    start_with:  3787389.4 i/s
                         match:  1467636.4 i/s - 2.58x slower
      
          Calculating -------------------------------------
                         match    36.694k i/100ms
                    start_with    86.071k i/100ms
          -------------------------------------------------
                         match    532.795k (± 4.7%) i/s -      2.679M
                    start_with      2.518M (± 5.8%) i/s -     12.566M
      
          Comparison:
                    start_with:  2518366.8 i/s
                         match:   532794.5 i/s - 4.73x slower
      113f8a6c
    • A
      Merge pull request #21097 from y-yagi/fix_button_to_example · 13beb92a
      Arun Agrawal 提交于
      correct example of button_tag [ci skip]
      13beb92a
    • Y
      correct example of button_tag [ci skip] · ac65bff3
      yuuji.yaginuma 提交于
      wrapper div has been removed in cbb91745
      ac65bff3
    • S
      Fix test failures caused by #20884 · 722abe17
      Sean Griffin 提交于
      PostgreSQL is strict about the usage of `DISTINCT` and `ORDER BY`, which
      one of the tests demonstrated. The order clause is never going to be
      relevant in the query we're performing, so let's just remove it
      entirely.
      722abe17
    • S
      Merge pull request #20884 · cc109111
      Sean Griffin 提交于
      Add #cache_key to ActiveRecord::Relation.
      cc109111
  4. 01 8月, 2015 5 次提交
  5. 31 7月, 2015 4 次提交