Permalink
Commits on Mar 10, 2018
  1. unfreeze TempleEngine precompiled string literals (#983)

    wjordan authored and k0kubun committed Mar 10, 2018
    Maintain backwards-compatibility in public API.
  2. Allow failures of Travis ruby-head

    k0kubun committed Mar 10, 2018
    Travis's ruby-head is too unstable to stabilize its builds. Obviously
    it's broken around rubygems.
Commits on Jan 3, 2018
Commits on Dec 29, 2017
  1. Fix Travis build matrix for Rails

    k0kubun committed Dec 29, 2017
    supported Ruby versions
  2. Upgrade Ruby versions on Travis

    k0kubun committed Dec 29, 2017
    and fix Bundler dep_proxy issue caused by RubyGems
Commits on Nov 15, 2017
  1. typo

    amatsuda committed Nov 15, 2017
Commits on Oct 29, 2017
  1. Frozen string literal changes (#967)

    oniofchaos authored and k0kubun committed Oct 29, 2017
    * Frozen string
    
    * Revert changes that are slower
    
    * Add object to map conversion for temple engine
    
    * Revert more frozen strings
    
    * Get rid of unnecessary extra array
    
    * Revert this change because it's slower in benchmarks
    
    * parser
    
    * true for filters
    
    * compiler
    
    * temple
    
    * finalize
Commits on Oct 26, 2017
  1. Merge pull request #965 from q-centrix/eval-interpolated-change

    amatsuda committed Oct 26, 2017
    Replace interpolated interpolation with cleaner method
  2. Revert "Add erubis to gemspec so that benchmark file can run"

    amatsuda committed Oct 26, 2017
    This reverts commit 0349ae4.
    
    Reason: The bundle in benchmark.rb fails now because the newest rails depends on erubi instead of erubis.
    It'd be better to update our script to use erubi with rails 5.1+ rather than adding a new dependency.
  3. Replace interpolated interpolation with cleaner method

    oniofchaos committed Oct 23, 2017
    In micro-benchmarking, this change performs within margin of error of
    the existing code but saves a string allocation each time the method is
    called (assuming the quote strings in the old code were frozen).
    
    ```
    begin
      require "bundler/inline"
    rescue LoadError => e
      $stderr.puts "Bundler version 1.10 or later is required. Please update
                    your Bundler"
      raise e
    end
    
    gemfile(true) do
      source "https://rubygems.org"
    
      gem "benchmark-ips"
    end
    
    def allocate_count
      GC.disable
      before = ObjectSpace.count_objects
      yield
      after = ObjectSpace.count_objects
      after.each { |k,v| after[k] = v - before[k] }
      after[:T_HASH] -= 1 # probe effect - we created the before hash.
      GC.enable
      result = after.reject { |k,v| v == 0 }
      GC.start
      result
    end
    
    interpolated = "hi"
    
      puts "'"' + interpolated + '"'"
      puts allocate_count { 1000.times { '"' + interpolated + '"' } }
      puts "%(\"\#{interpolated}\")"
      puts allocate_count { 1000.times { %("#{interpolated}") } }
      puts "\"\#{interpolated}\""
      puts allocate_count { 1000.times { "\"#{interpolated}\"" } }
    
    Benchmark.ips do |x|
      x.report("'"' + interpolated + '"'") { '"' + interpolated + '"' }
      x.report("%(\"\#{interpolated}\")")  { %("#{interpolated}") }
      x.report("\"\#{interpolated}\"")     { "\"#{interpolated}\"" }
      x.compare!
    end
    ```ruby
    
    ```
    ' + interpolated + '
    {:FREE=>-1892, :T_STRING=>2052}
    %("#{interpolated}")
    {:FREE=>-1001, :T_STRING=>1000}
    "#{interpolated}"
    {:FREE=>-1001, :T_STRING=>1000}
    Warming up --------------------------------------
    ' + interpolated + '    81.706k i/100ms
    %("#{interpolated}")   106.128k i/100ms
       "#{interpolated}"   137.855k i/100ms
    Calculating -------------------------------------
    ' + interpolated + '      3.892M (±23.2%) i/s -     17.975M in   5.007068s
    %("#{interpolated}")      3.722M (±17.3%) i/s -     17.830M in   5.022549s
       "#{interpolated}"      3.725M (±15.0%) i/s -     18.059M in   5.023493s
    
    Comparison:
    ' + interpolated + ':  3892392.6 i/s
       "#{interpolated}":  3725385.8 i/s - same-ish: difference falls within error
    %("#{interpolated}"):  3722401.7 i/s - same-ish: difference falls within error
    ```
  4. Merge pull request #963 from q-centrix/attribute-builder-change

    amatsuda committed Oct 26, 2017
    Rewrite old attribute mapping to save many object allocations
  5. Add constant for default content_tag_with_haml options

    oniofchaos committed Oct 25, 2017
    This saves an array allocation each time the method is called.
    
    ```ruby
    begin
      require "bundler/inline"
    rescue LoadError => e
      $stderr.puts "Bundler version 1.10 or later is required. Please update
                    your Bundler"
      raise e
    end
    
    gemfile(true) do
      source "https://rubygems.org"
    
      gem "benchmark-ips"
      gem "rails"
    end
    
    def allocate_count
      GC.disable
      before = ObjectSpace.count_objects
      yield
      after = ObjectSpace.count_objects
      after.each { |k,v| after[k] = v - before[k] }
      after[:T_HASH] -= 1 # probe effect - we created the before hash.
      GC.enable
      result = after.reject { |k,v| v == 0 }
      GC.start
      result
    end
    
    DEFAULT_PRESERVE_OPTIONS = %w(textarea pre code).freeze
    @hash = {}
    
    def master_version
      {}.fetch(:preserve, %w(textarea pre code))
    end
    
    def fast_version
      {}.fetch(:preserve, DEFAULT_PRESERVE_OPTIONS)
    end
    
    puts "master_version"
    puts allocate_count { 1000.times { master_version } }
    puts "fast_version"
    puts allocate_count { 1000.times { fast_version } }
    
    Benchmark.ips do |x|
      x.report("master_version") { master_version }
      x.report("fast_version")     { fast_version }
      x.compare!
    end
    ```
    
    ```ruby
    master_version
    {:FREE=>-1812, :T_STRING=>52, :T_ARRAY=>1000, :T_HASH=>1000}
    fast_version
    {:FREE=>-1001, :T_HASH=>1000}
    Warming up --------------------------------------
          master_version   127.040k i/100ms
            fast_version    79.789k i/100ms
    Calculating -------------------------------------
          master_version      3.310M (±35.6%) i/s -     13.212M in   5.007796s
            fast_version      5.899M (±19.3%) i/s -     28.166M in   5.016644s
    
    Comparison:
            fast_version:  5899290.2 i/s
          master_version:  3310098.8 i/s - 1.78x  slower
    ```
    
    Results of `benchmark.rb`
    ```
                                             Haml |     ERB |  Erubis |
    -------------------------------------------------------------------
    Cached                                  0.089 |   0.080 |   0.062 |
    ActionView                             18.273 |  12.743 |         |
    ActionView with deep partials          44.632 |  43.307 |         |
    ```
    
    compared to current master:
    ```
                                             Haml |     ERB |  Erubis |
    -------------------------------------------------------------------
    Cached                                  0.174 |   0.420 |   0.224 |
    ActionView                             21.360 |  11.631 |         |
    ActionView with deep partials          43.563 |  39.238 |         |
    ```
  6. CHANGELOG.md note

    oniofchaos committed Oct 26, 2017
  7. Rewrite old attribute mapping to save many object allocations

    oniofchaos committed Oct 24, 2017
    Stringifying the keys of a hash can be done without allocating many
    arrays like the previous approach did.
    
    ```ruby
    begin
      require "bundler/inline"
    rescue LoadError => e
      $stderr.puts "Bundler version 1.10 or later is required. Please update
                    your Bundler"
      raise e
    end
    
    gemfile(true) do
      source "https://rubygems.org"
    
      gem "benchmark-ips"
    end
    
    def allocate_count
      GC.disable
      before = ObjectSpace.count_objects
      yield
      after = ObjectSpace.count_objects
      after.each { |k,v| after[k] = v - before[k] }
      after[:T_HASH] -= 1 # probe effect - we created the before hash.
      GC.enable
      result = after.reject { |k,v| v == 0 }
      GC.start
      result
    end
    
    @old = {a: :b, c: :d, e: :f}
    
    def master_version
      Hash[@old.map { |k, v| [k.to_s, v] }]
    end
    
    def fast_version
      result = {}
      @old.each { |k, v| result[k.to_s] = v }
    end
    
    puts "master_version"
    puts allocate_count { 1000.times { master_version } }
    puts "fast_version"
    puts allocate_count { 1000.times { fast_version } }
    
    Benchmark.ips do |x|
      x.report("master_version") { master_version }
      x.report("fast_version")     { fast_version }
      x.compare!
    end
    ```
    
    ```ruby
    master_version
    {:FREE=>-14768, :T_STRING=>6054, :T_ARRAY=>7000, :T_HASH=>1000, :T_IMEMO=>1000}
    fast_version
    {:FREE=>-7001, :T_STRING=>6000, :T_HASH=>1000}
    Warming up --------------------------------------
          master_version    38.137k i/100ms
            fast_version    50.133k i/100ms
    Calculating -------------------------------------
          master_version    451.898k (±19.2%) i/s -      2.174M in   5.002186s
            fast_version    633.579k (±19.4%) i/s -      3.058M in   5.019391s
    
    Comparison:
            fast_version:   633578.7 i/s
          master_version:   451897.6 i/s - same-ish: difference falls within error
    ```
  8. Merge pull request #964 from q-centrix/fix-for-benchmark

    amatsuda committed Oct 26, 2017
    Add erubis to gemspec so that benchmark file can run
Commits on Oct 25, 2017
Commits on Oct 20, 2017
  1. Tidy up --exclude options in .yardopts (#960)

    erikse authored and k0kubun committed Oct 20, 2017
    * Remove .yardopts exclude for removed file patch.rb
    
    Seems like this file is no longer, deleted in c1ff325.
    
    * Update .yardopts exclude path for plugin.rb
    
    Set path to new location of patch.rb file updated in 308e3ca.
Commits on Oct 14, 2017
  1. Make sure to load rails before loading haml

    amatsuda committed Oct 14, 2017
    Or haml/railtie will not be required.
    
    This normally will be done inside haml-rails for the users' apps, but since
    we're not depending on haml-rails in this repo to avoid mutual dependency,
    we need to carefully craft the gem load order here.
Commits on Oct 13, 2017
  1. Version 5.0.4

    amatsuda committed Oct 13, 2017
  2. typo

    amatsuda committed Oct 13, 2017
  3. CI against ruby-head

    amatsuda committed Oct 13, 2017
Commits on Sep 25, 2017
  1. Merge pull request #958 from TeaMoe/stdin

    k0kubun committed Sep 25, 2017
    haml -c --stdin fix
Commits on Sep 15, 2017
Commits on Sep 14, 2017
  1. haml -c --stdin fix

    TeaMoe committed Sep 14, 2017
    see #957