1. 19 9月, 2015 4 次提交
  2. 18 9月, 2015 4 次提交
  3. 15 9月, 2015 1 次提交
    • A
      Improve Docs of ActiveSupport::TimeZone [ci skip] · 4818f3e1
      amitkumarsuroliya 提交于
      `TimeZone` class is a part of `ActiveSupport` module. For Accessing `TimeZone` class, we need to call `ActiveSupport::TimeZone` instead of `TimeZone`.
      
      individual `TimeZone` gives `NameError: uninitialized constant ‘TimeZone’ error
      4818f3e1
  4. 14 9月, 2015 1 次提交
    • C
      Remove AS methods that are never invoked · 45ccc462
      claudiob 提交于
      Fixes #21122 - does not change any current behavior; simply reflects
      the fact that two conditions of the if/else statement are never reached.
      
      The reason is #17227 which adds a default terminator to AS::Callbacks.
      
      Therefore, even callback chains that do not define a terminator now
      have a terminator, and `chain_config.key?(:terminator)` is always true.
      
      Of course, if no terminator was defined, then we want this new default
      terminator not to do anything special. What the terminator actually does
      (or should do) is discussed in #21218 but the simple fact that a default
      terminator exists makes this current PR valid.
      
      *Note* that the conditional/simple methods have not been removed in
      AS::Conditionals::Filter::After because of `:skip_after_callbacks_if_terminated`
      which lets a user decide **not** to skip after callbacks even if the chain was
      terminated.
      45ccc462
  5. 13 9月, 2015 1 次提交
    • A
      Improving `in_time_zone` docs [ci skip] · 7251533f
      amitkumarsuroliya 提交于
      
      `DateTime.utc` is not a valid method. It gives `NoMethodError: undefined method `utc` for DateTime:Class`. As we know that we can calculate `utc` time from `Time` Class, but we can’t calculate `utc` time from `DateTime` Class.
      7251533f
  6. 12 9月, 2015 1 次提交
    • J
      Improve String#strip_heredoc · 503d3345
      Juanito Fatas 提交于
      Saves about 6 MB, about 40% faster.
      
      **strip_heredoc.rb**
      
      ```ruby
      require "active_support/core_ext/object/try"
      require "get_process_mem"
      
      class String
        def strip_heredoc
          indent = scan(/^[ \t]*(?=\S)/).min.try(:size) || 0
          gsub(/^[ \t]{#{indent}}/, '')
        end
      end
      
      if ENV["MEASURE_MEMORY"] == "yes"
        mem = GetProcessMem.new
        GC.start
        GC.disable
        10000.times do
          <<-MSG.strip_heredoc
            xhr and xml_http_request methods are deprecated in favor of
            `get :index, xhr: true` and `post :create, xhr: true`
          MSG
        end
        before = mem.mb
      
        after = mem.mb
        GC.enable
        puts "Before: #{before} MiB"
        puts "After: #{after} MiB"
        puts "Diff: #{after - before} MiB"
      end
      ```
      
      **patched_strip_heredoc.rb**
      
      ```ruby
      require "active_support/core_ext/object/try"
      require "get_process_mem"
      
      class String
        def patched_strip_heredoc
          gsub(/^#{scan(/^[ \t]*(?=\S)/).min}/, "".freeze)
        end
      end
      
      if ENV["MEASURE_MEMORY"] == "yes"
        mem = GetProcessMem.new
        GC.start
        GC.disable
        10000.times do
          <<-MSG.patched_strip_heredoc
            xhr and xml_http_request methods are deprecated in favor of
            `get :index, xhr: true` and `post :create, xhr: true`
          MSG
        end
        before = mem.mb
      
        after = mem.mb
        GC.enable
        puts "Before: #{before} MiB"
        puts "After: #{after} MiB"
        puts "Diff: #{after - before} MiB"
      end
      ```
      
      **Before**
      
      ```
      $ MEASURE_MEMORY=yes ruby strip_heredoc.rb
      Before: 44.73828125 MiB
      After: 44.7734375 MiB
      Diff: 0.03515625 MiB
      ```
      
      **After**
      
      ```
      $ MEASURE_MEMORY=yes ruby patched_strip_heredoc.rb
      Before: 37.9765625 MiB
      After: 38.015625 MiB
      Diff: 0.0390625 MiB
      ```
      
      `44.7734375 -  38.015625 = 6.75`
      
      => **Saves about 6.75 MiB**
      
      **benchmark.rb**
      
      ```ruby
      require "benchmark/ips"
      require_relative "./strip_heredoc"
      require_relative "./patched_strip_heredoc"
      
      def original
        <<-MSG.strip_heredoc
          xhr and xml_http_request methods are deprecated in favor of
          `get :index, xhr: true` and `post :create, xhr: true`
        MSG
      end
      
      def patched
        <<-MSG.patched_strip_heredoc
          xhr and xml_http_request methods are deprecated in favor of
          `get :index, xhr: true` and `post :create, xhr: true`
        MSG
      end
      
      Benchmark.ips do |x|
        x.report("original") { original }
        x.report(" patched") { patched  }
        x.compare!
      end
      ```
      
      ```
      $ ruby -v benchmark.rb
      ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-darwin14]
      Calculating -------------------------------------
                  original     5.652k i/100ms
                   patched     6.477k i/100ms
      -------------------------------------------------
                  original     54.076k (± 5.7%) i/s -    271.296k
                   patched     74.557k (± 6.2%) i/s -    375.666k
      
      Comparison:
                   patched:    74557.0 i/s
                  original:    54076.4 i/s - 1.38x slower
      ```
      
      => **About 38% faster**
      
      1. Clone rails project `git clone git@github.com:rails/rails.git`
      2. Apply this patch to
      `activesupport/lib/active_support/core_ext/string/strip.rb`
      3. `cd activesupport`
      4. run `rake`
      5. And tests passed:
      
      ```
      ➜ activesupport $ rake
      /Users/Juan/.rubies/ruby-2.2.2/bin/ruby -w -I"lib:test"
      "/Users/Juan/.rubies/ruby-2.2.2/lib/ruby/2.2.0/rake/rake_test_loader.rb"
       "test/**/*_test.rb"
      
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ........................................................................
      ......................................................................S.
      SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS
      
      Finished in 15.343004s, 214.2344 runs/s, 24902.4898 assertions/s.
      
      3287 runs, 382079 assertions, 0 failures, 0 errors, 48 skips
      
      You have skipped tests. Run with --verbose for details.
      ```
      503d3345
  7. 10 9月, 2015 1 次提交
  8. 09 9月, 2015 2 次提交
  9. 06 9月, 2015 1 次提交
  10. 04 9月, 2015 1 次提交
  11. 03 9月, 2015 1 次提交
  12. 02 9月, 2015 1 次提交
  13. 29 8月, 2015 1 次提交
    • L
      ArrayInquirer to correctly find symbols or strings · 7abbe137
      Leigh Halliday 提交于
      The problem existed where if your ArrayInquirer values were
      strings but you checked them using any? with a symbol, it would
      not find the value. Now it will correctly check whether both
      the String form or the Symbol form are included in the Array.
      
      `
      7abbe137
  14. 28 8月, 2015 3 次提交
    • R
      Tiny documentation improvements [ci skip] · 7a27de2b
      Robin Dupret 提交于
      7a27de2b
    • V
      - Extracted `DELIMITED_REGEX` to `delimited_regex` method and made use of ... · 7f23c5d5
      Vipul A M 提交于
      - Extracted `DELIMITED_REGEX` to `delimited_regex` method and made use of  user passed `options[:delimited_regex]` if available. Changed `DELIMITED_REGEX` to `DEFAULT)DELIMITED_REGEX` to signify what it means.
      - Added tests for number to delimited and number to currency in both actionview and activesupport.
      
      Changes
      
      Changes
      7f23c5d5
    • J
      10X speed improvements for AS::Dependencies.loadable_constants_for_path · 2e0cd0f3
      Jean Boussier 提交于
      When the autoload_paths start to grows, this methods is quite a hotspot
      
      >> ActiveSupport::Dependencies.autoload_paths.size
      => 49
      
      >> Benchmark.ips { |x| x.report('baseline') { ActiveSupport::Dependencies.loadable_constants_for_path(File.expand_path('app/models/shop')) }}
      Calculating -------------------------------------
                  baseline    90.000  i/100ms
      -------------------------------------------------
                  baseline      1.073k (±20.2%) i/s -      4.950k
      
      After the patch
      
      Calculating -------------------------------------
                   patched   883.000  i/100ms
      -------------------------------------------------
                   patched     11.050k (±19.7%) i/s -     50.331k
      2e0cd0f3
  15. 26 8月, 2015 1 次提交
  16. 25 8月, 2015 3 次提交
  17. 20 8月, 2015 3 次提交
  18. 18 8月, 2015 2 次提交
    • R
      Added docs for TimeWithZone [ci skip] · ef9caad6
      Ronak Jangir 提交于
      ef9caad6
    • J
      Use == 0 instead of .zero? in #try · a94c2e1f
      Jean Boussier 提交于
      The perf gain is relatively minor but consistent:
      
      ```
      Calculating -------------------------------------
                   0.zero?   137.091k i/100ms
                   1.zero?   137.350k i/100ms
                    0 == 0   142.207k i/100ms
                    1 == 0   144.724k i/100ms
      -------------------------------------------------
                   0.zero?      8.893M (± 6.5%) i/s -     44.280M
                   1.zero?      8.751M (± 6.4%) i/s -     43.677M
                    0 == 0     10.033M (± 7.0%) i/s -     49.915M
                    1 == 0      9.814M (± 8.0%) i/s -     48.772M
      ```
      
      And try! is quite a big hotspot for us so every little gain is appreciable.
      a94c2e1f
  19. 17 8月, 2015 1 次提交
  20. 15 8月, 2015 1 次提交
  21. 13 8月, 2015 1 次提交
  22. 12 8月, 2015 1 次提交
  23. 11 8月, 2015 2 次提交
  24. 10 8月, 2015 1 次提交
  25. 09 8月, 2015 1 次提交