Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't preserve newlines in attributes #903

Merged
merged 1 commit into from Feb 9, 2017

Conversation

k0kubun
Copy link
Member

@k0kubun k0kubun commented Feb 8, 2017

Haml::Helpers.preserve is very slow. I don't think it's necessary for attributes because Slim, Faml and Hamlit don't preserve them and work fine.

The original change was done in 2008 e8075e7 and no reason is found to keep that change. Let's remove a legacy feature.

Benchmark

With Ruby 2.4.0 and k0kubun/haml_bench/templates/slim_bench.haml,

before

$ bundle exec ruby bench.rb
Rendering: /home/k0kubun/src/github.com/k0kubun/haml_bench/templates/slim_bench.haml
Calculating -------------------------------------
          haml 4.0.7     3.576k i/100ms
   haml 5.0.0.beta.2     5.450k i/100ms
-------------------------------------------------
          haml 4.0.7     37.559k (± 3.6%) i/s -    189.528k
   haml 5.0.0.beta.2     55.625k (± 4.5%) i/s -    277.950k

Comparison:
   haml 5.0.0.beta.2:    55625.3 i/s
          haml 4.0.7:    37558.8 i/s - 1.48x slower

after

$ bundle exec ruby bench.rb
Rendering: /home/k0kubun/src/github.com/k0kubun/haml_bench/templates/slim_bench.haml
Calculating -------------------------------------
          haml 4.0.7     3.608k i/100ms
   haml 5.0.0.beta.2     6.140k i/100ms
-------------------------------------------------
          haml 4.0.7     37.460k (± 3.5%) i/s -    187.616k
   haml 5.0.0.beta.2     64.248k (± 4.5%) i/s -    325.420k

Comparison:
   haml 5.0.0.beta.2:    64247.5 i/s
          haml 4.0.7:    37459.9 i/s - 1.72x slower

@haml/committers WDYT?

@k0kubun
Copy link
Member Author

k0kubun commented Feb 9, 2017

I finished attribute compiler implementation using this. Merging for now. Please give me your opinions later.

@k0kubun k0kubun merged commit c6c085b into haml:master Feb 9, 2017
@k0kubun k0kubun deleted the dont-preserve-attributes branch February 9, 2017 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant