aboutsummaryrefslogtreecommitdiffstats
path: root/actionview/lib/action_view/helpers/tag_helper.rb
Commit message (Collapse)AuthorAgeFilesLines
* Test to check if the data-attr if nil is same or notSourav Moitra2016-02-141-0/+1
| | | | | | | | | | if data attribute is nil it is ignored if value is nil the pair is ignored if value is nil it is skipped Improved test for data attr nil
* Save a string allocation inside loopBenjamin Quorning2015-08-021-3/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Don't allocate array when not necessaryschneems2015-07-301-5/+6
| | | | | | In the `tag_options` method an array is used to build up elements, then `Array#*` (which is an alias for `Array#join` is called to turn the array into a string. Instead of allocating an array to build a string, we can build the string we want from the beginning. Saved: 121,743 bytes 893 objects
* Decrease string allocation in content_tag_stringschneems2015-07-291-6/+7
| | | | | | | | | | When an unknonwn key is passed to the hash in `PRE_CONTENT_STRINGS` it returns nil, when you call "#{nil}" it allocates a new empty string. We can get around this allocation by using a default value `Hash.new { "".freeze }`. We can avoid the `to_sym` call by pre-populating the hash with a symbol key in addition to a string key. We can freeze some strings when using Array#* to reduce allocations. Array#join can take frozen strings. This change buys us 86,600 bytes of memory and 1,857 fewer objects per request.
* Pass symbol as an argument instead of a blockErik Michaels-Ober2014-11-291-1/+1
|
* Call gsub with a Regexp instead of a String for better performancePablo Herrero2014-11-011-1/+1
|
* remove un-needed sortschneems2014-10-071-1/+1
| | | | | | HTML doesn't care what order the elements are rendered in, so why should we? Updates tests to use proper `assert_dom_equal` instead of `assert_equal` /cc @jeremy
* Extract data/aria attribute prefixes to a constantRafael Mendonça França2014-09-031-1/+3
|
* Add support for ARIA attributes in tagsPaoMar2014-09-031-4/+4
|
* Include missing module in tag_helperCarlos Antonio da Silva2014-07-091-0/+1
| | | | | | | | | Since 6857415187810f1289068a448268264d0cf0844f we are using #safe_join to join the content when an Array is given, so we must include the dependent module here to make sure it's available when this module is used alone. This was making Simple Form tests to fail with current master due to the missing dependency.
* Merge pull request #15654 from pdg137/masterMatthew Draper2014-06-131-2/+5
|\ | | | | | | In tag helper, honor html_safe on arrays; also make safe_join more similar to Array.join
| * In tag helper, honor html_safe on array parameters; also make safe_join more ↵Paul Grayson2014-06-121-3/+15
|/ | | | similar to Array.join by first calling flatten.
* drastically reduce object allocationsAaron Patterson2014-06-021-2/+2
| | | | | | | | | | before this change, we were allocating AS::SafeBuffer objects that were being interpolated in to a string, so the safe buffer object was being thrown away. This change only allocates a string (vs a string *and* a safebuffer) and interpolates the string. On my test application, this reduced the AS::SafeBuffer objects from 1527k per request to about 500 per request.
* Update doc for TagHelper.Hendy Tanata2014-03-051-2/+8
|
* Allocate one less object using html_safe during content_tag constructionJosh Jordan2013-11-141-1/+1
|
* Convert CDATA input to string before gsub'ingCarsten Zimmermann2013-10-291-1/+1
| | | | | Rails 3.2 API allowed arbitrary input for cdata_section; this change re-introduces the old behaviour.
* Move actionpack/lib/action_view* into actionview/libPiotr Sarnacki2013-06-201-0/+176