- 09 3月, 2019 1 次提交
-
-
由 Abhay Nikam 提交于
-
- 01 3月, 2019 1 次提交
-
-
由 Xavier Noria 提交于
A string S matches ([.]|\b)html if an only if matches \bhtml: * If S matches [.]html, then it matches \bhtml. * If S matches \bhtml, then it matches \bhtml. Reciprocally: * If S matches \bhtml, then it matches ([.]|\b)html. The character class can be removed, and since we are on it we remove the group too so that it is clear to a reader of the code that there is no grouping going on. References #35166.
-
- 05 2月, 2019 1 次提交
-
-
由 Kazuhiro NISHIYAMA 提交于
- Use `\z` instead of `$` - Use character class instead of alternation - Optimize alternation order
-
- 23 9月, 2018 1 次提交
-
-
由 yuuji.yaginuma 提交于
In Ruby 2.3 or later, `String#+@` is available and `+@` is faster than `dup`. ```ruby # frozen_string_literal: true require "bundler/inline" gemfile(true) do source "https://rubygems.org" gem "benchmark-ips" end Benchmark.ips do |x| x.report('+@') { +"" } x.report('dup') { "".dup } x.compare! end ``` ``` $ ruby -v benchmark.rb ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux] Warming up -------------------------------------- +@ 282.289k i/100ms dup 187.638k i/100ms Calculating ------------------------------------- +@ 6.775M (± 3.6%) i/s - 33.875M in 5.006253s dup 3.320M (± 2.2%) i/s - 16.700M in 5.032125s Comparison: +@: 6775299.3 i/s dup: 3320400.7 i/s - 2.04x slower ```
-
- 03 7月, 2018 1 次提交
-
-
由 Juan Broullon 提交于
-
- 28 4月, 2018 1 次提交
-
-
由 Max Melentiev 提交于
-
- 23 3月, 2018 1 次提交
-
-
由 Dillon Welch 提交于
If the options passed in don't have a default key, there's no point in creating an array from those empty results when we can just go straight to creating an empty array. Benchmarks: ```ruby master_version with false {:FREE=>-2497, :T_STRING=>52, :T_ARRAY=>2000, :T_HASH=>1000, :T_IMEMO=>1} master_version with true {:FREE=>-3001, :T_ARRAY=>2000, :T_HASH=>1000} fast_version with false {:FREE=>-1001, :T_ARRAY=>1000} fast_version with true {:FREE=>-3001, :T_ARRAY=>2000, :T_HASH=>1000} Warming up -------------------------------------- master_version with false 104.985k i/100ms master_version with true 118.737k i/100ms fast_version with false 206.013k i/100ms fast_version with true 107.005k i/100ms Calculating ------------------------------------- master_version with false 1.970M (±24.6%) i/s - 8.924M in 5.010302s master_version with true 2.152M (±12.4%) i/s - 10.686M in 5.051588s fast_version with false 5.613M (±19.6%) i/s - 26.782M in 5.003740s fast_version with true 2.027M (±15.8%) i/s - 9.951M in 5.065670s Comparison: fast_version with false: 5613159.2 i/s master_version with true: 2152354.4 i/s - 2.61x slower fast_version with true: 2027296.0 i/s - 2.77x slower master_version with false: 1969824.9 i/s - 2.85x slower ``` Benchmark code: ```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 def master_version(key) Array({}.delete(:default)).compact end def fast_version(key) if key Array({}.delete(:default)).compact else [] end end def test puts "master_version with false" puts allocate_count { 1000.times { master_version(false) } } puts "master_version with true" puts allocate_count { 1000.times { master_version(true) } } puts "fast_version with false" puts allocate_count { 1000.times { fast_version(false) } } puts "fast_version with true" puts allocate_count { 1000.times { fast_version(true) } } Benchmark.ips do |x| x.report("master_version with false") { master_version(false) } x.report("master_version with true") { master_version(true) } x.report("fast_version with false") { fast_version(false) } x.report("fast_version with true") { fast_version(true) } x.compare! end end test ```
-
- 20 3月, 2018 1 次提交
-
-
由 Dillon Welch 提交于
This gets called many times for each virtual_path, creating a new string each time that `translate` is called. We can memoize this so that it only happens once per virtual_path instead.
-
- 21 10月, 2017 1 次提交
-
-
由 Akira Matsuda 提交于
This basically reverts c4d1a4ef
-
- 27 8月, 2017 1 次提交
-
-
由 Yoshiyuki Hirano 提交于
-
- 24 7月, 2017 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 02 7月, 2017 1 次提交
-
-
由 Matthew Draper 提交于
This reverts commit 3420a145, reversing changes made to afb66a5a.
-
- 01 7月, 2017 2 次提交
-
-
由 Akira Matsuda 提交于
-
由 Kir Shatrov 提交于
-
- 20 6月, 2017 1 次提交
-
-
由 Pat Allan 提交于
Plus a couple of related ActionPack patches.
-
- 03 6月, 2017 1 次提交
-
-
由 Genadi Samokovarov 提交于
-
- 27 10月, 2016 1 次提交
-
-
由 Xavier Noria 提交于
Regexp#match? should be considered to be part of the Ruby core library. We are emulating it for < 2.4, but not having to require the extension is part of the illusion of the emulation.
-
- 07 8月, 2016 1 次提交
-
-
由 Xavier Noria 提交于
The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
-
- 25 7月, 2016 1 次提交
-
-
由 Xavier Noria 提交于
Where appropriate, prefer the more concise Regexp#match?, String#include?, String#start_with?, or String#end_with?
-
- 19 12月, 2015 1 次提交
-
-
由 Sameer Rahmani 提交于
`I18n.translate` helper will wrap the missing translation keys in a <span> tag only if `debug_missing_translation` configuration has a truthy value. Default value is `true`. For example in `application.rb`: # in order to turn off missing key wrapping config.action_view.debug_missing_translation = false
-
- 29 10月, 2015 1 次提交
-
-
由 Kasper Timm Hansen 提交于
It's already represented in the key name. Demonstrate with a test. Also test that the default isn't output.
-
- 19 9月, 2015 1 次提交
-
-
由 Kir Shatrov 提交于
-
- 05 5月, 2015 2 次提交
-
-
由 Bernard Potocki 提交于
-
由 Bernard Potocki 提交于
-
- 24 4月, 2015 1 次提交
-
-
由 Derek Prior 提交于
The documentation previously stated that calling `translate(".foo")` was equivalent to calling `I18n.translate("people.index.foo")` which is incorrect due to the various other functions of the `translate` view helper. This has been fixed. Additionally, a note about forcing the view helper to re-raise exceptions was added to the section detailing the handling of missing translations. Other cleanup includes: * Consistent formatting of code * Stop indenting bulleted list as a code sample * Tighten some of the language * Wrap at 80 characters.
-
- 05 4月, 2015 1 次提交
-
-
由 Adam Prescott 提交于
4.2.1 introduced a change to the way `translate`/`t` works with an option of `default: [[]]`. In 4.2.0, this would give a default value of `[]`, but in 4.2.1, it leads to a missing translation. `default: [[]]` is again allowed for cases where a default of `[]` is needed. This addresses GitHub issue 19640.
-
- 21 3月, 2015 1 次提交
-
-
由 Rafael Mendonça França 提交于
Strip nils out of default translations. Fixes #19419
-
- 27 2月, 2015 1 次提交
-
-
由 Ulisses Almeida 提交于
The previous version of rails(4.2.0) you can pass objects to the default option of translation helper. For example: ```ruby t('foo', default: 1) ``` But on rails 4.2.1 version this kind of use stopped to work, because started only to accept String types. Now with this fix we can use orther value types on this helper again.
-
- 03 1月, 2015 1 次提交
-
-
由 Justin Coyne 提交于
Previously default translation keys that didn't end in `_html`, but came after a missing key that ended in `_html` were being returned as html_safe. Now they are not. Fixes #18257
-
- 19 11月, 2014 1 次提交
-
-
由 Christopher Dell 提交于
Previously, when the `:raise` options was set to `false`, it would get overwritten to `true`, preventing custom exception handlers to be used.
-
- 06 9月, 2014 1 次提交
-
-
由 Rajarshi Das 提交于
not required include ActionView::Helpers::TagHelper in test as well
-
- 14 8月, 2014 1 次提交
-
-
由 Akira Matsuda 提交于
-
- 13 5月, 2014 2 次提交
-
-
由 Carlos Antonio da Silva 提交于
-
由 Josep Jaume Rey 提交于
`options[:default]` and `options[:raise]` can be mistakenly added to the `options` hash. This can be a problem if you're reusing the same object.
-
- 27 1月, 2014 1 次提交
-
-
由 Kassio Borges 提交于
Add a config to setup whether raise exception for missing translation or not.
-
- 05 12月, 2013 1 次提交
-
-
由 Shota Fukumori (sora_h) 提交于
Before ec16ba75, ActionView::Helpers::TranslationHelper#translate has raised errors with specifying options[:raise] to true. This should work by this fix: begin t(:"translations.missing", raise: true) rescue I18n::MissingTranslationData p :hello! end
-
- 03 12月, 2013 1 次提交
-
-
由 Michael Koziarski 提交于
i18n doesn't depend on active support which means it can't use our html_safe code to do its escaping when generating the spans. Rather than try to sanitize the output from i18n, just revert to our old behaviour of rescuing the error and constructing the tag ourselves. Fixes: CVE-2013-4491
-
- 20 6月, 2013 1 次提交
-
-
由 Piotr Sarnacki 提交于
-
- 29 10月, 2012 1 次提交
-
-
由 AvnerCohen 提交于
-
- 23 5月, 2012 1 次提交
-
-
由 Philip Arndt 提交于
* Added tests for 'else' case in ActionView::Helpers::TranslationHelper#wrap_translate_defaults * Also updated the testing syntax of translation.html_safe? asserts to provide better output upon failure.
-