summaryrefslogtreecommitdiff
path: root/lib
AgeCommit message (Collapse)Author
2017-06-09Fix typo.a_matsuda
Patch by: Sarah Duve Signed-off-by: Akira Matsuda <ronnie@dio.jp> [Fix GH-1643] [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59049 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-06-07rexml: add close tag check on end of document to StreamParserkou
[ruby-core:81593] [Bug #13636] Reported by Anton Sivakov. Thanks!!! git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59033 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-28suppress warning: ambiguous first argument; put parentheses or a space even ↵naruse
after `-' operator Introduced at r58905 http://rubyci.s3.amazonaws.com/ubuntu/ruby-trunk/log/20170526T153003Z.diff.html.gz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58948 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-27erb.rb: Use str_uplus instead of rb_str_dupk0kubun
to skip unnecessary string allocation on frozen_string_literal: false. str_uplus can bypass calling rb_str_dup when OBJ_FROZEN is true. * Before erb_render 1.064 * Afete erb_render 0.909 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58916 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26erb.rb: Tiny improvement of compiling costk0kubun
by reducing string allocation. * Before app_erb 0.687 * After app_erb 0.679 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58908 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26erb.rb: [DOC] Follow compiled code's changek0kubun
introduced in r58905. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58907 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26erb.rb: Generate static string with opt_str_uminusk0kubun
to skip object allocation for static string. We can't always enable frozen_string_literal pragma because we can't freeze string literals embedded by user for backward compatibility. So we need to use fstring for each static string. Since adding ".freeze" to string literals in #content_dump is slow on compiling, I used unary "-" operator instead. benchmark/bm_app_erb_render.rb: Added rendering-only benchmark to test rendering performance on production environment. This benchmark is created to reproduce the behavior on Sinatra (Tilt). Thus it doesn't use ERB#result to skip parsing compiled code. It doesn't use ERB#def_method too to regard `title` and `content` as local variables. If we use #def_method, `title` and `content` needs to be method call. I wanted to avoid it. This patch's benchmark results is: * Before app_erb_render 1.250 app_erb 0.704 * After app_erb_render 1.066 app_erb 0.686 This patch optimizes rendering performance (app_erb_render) without spoiling (total of rendering +) compiling performance (app_erb). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58905 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26erb.rb: Use script encoding instead of force_encodingk0kubun
The original intention of introducing `_erbout.force_encoding` in r21170 was: - "returns a string in the same character encoding as the input string." - "When the input string has a magic comment, however, it returns a string in the encoding specified by the magic comment." And they are tested by test/erb/test_erb_m17n.rb well and this patch passes the test. Since magic comment is always added in ERB compiled code, using ''.dup instead of String.new will set correct encoding without calling force_encoding method. The benchmark results are: * Before $ ./ruby benchmark/run.rb --matzruby=./ruby -m bm_app_erb MatzRuby: ruby 2.5.0dev (2017-05-26 skip-force-enc.. 58903) [x86_64-linux] last_commit=Skip force_encoding in compiled code of erb Ruby: app_erb: matz 0.715 * After $ ./ruby benchmark/run.rb --matzruby=./ruby -m bm_app_erb MatzRuby: ruby 2.5.0dev (2017-05-26 skip-force-enc.. 58903) [x86_64-linux] last_commit=Skip force_encoding in compiled code of erb Ruby: app_erb: matz 0.672 And perf(1) results are: * Before $ sudo perf stat ./ruby benchmark/bm_app_erb.rb Performance counter stats for './ruby benchmark/bm_app_erb.rb': 709.571746 task-clock (msec) # 1.000 CPUs utilized 5 context-switches # 0.007 K/sec 1 cpu-migrations # 0.001 K/sec 1,337 page-faults # 0.002 M/sec 3,088,936,521 cycles # 4.353 GHz <not supported> stalled-cycles-frontend <not supported> stalled-cycles-backend 4,849,564,282 instructions # 1.57 insns per cycle 1,027,042,087 branches # 1447.411 M/sec 19,983,456 branch-misses # 1.95% of all branches 0.709747823 seconds time elapsed * After $ sudo perf stat ./ruby benchmark/bm_app_erb.rb Performance counter stats for './ruby benchmark/bm_app_erb.rb': 693.494673 task-clock (msec) # 1.000 CPUs utilized 7 context-switches # 0.010 K/sec 1 cpu-migrations # 0.001 K/sec 1,316 page-faults # 0.002 M/sec 3,025,639,349 cycles # 4.363 GHz <not supported> stalled-cycles-frontend <not supported> stalled-cycles-backend 4,694,848,271 instructions # 1.55 insns per cycle 994,496,704 branches # 1434.037 M/sec 19,693,239 branch-misses # 1.98% of all branches 0.693724345 seconds time elapsed [fix GH-1147] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58904 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-26* lib/uri/common.rb: [DOC] add rdoc to describesonots
URI.unescape is obsolete [ci-skip] [fix GH-1630] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58899 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-25erb.rb: Add ERB#result_with_hashk0kubun
[ruby-core:55985] [Feature #8631] [fix GH-1623] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58891 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-22lib/net/protocol.rb: account read_bytes before caller sees itnormal
Users may modify the chunk yielded to them in Net::HTTPResponse#read_body. This will allow users to reduce memory usage by calling String#clear on the buffer once they're done using it. * lib/net/protocol.rb (read): increment read_bytes earlier (read_all): ditto * test/net/http/test_httpresponse.rb (test_read_body_block_mod): new test git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58846 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-22net/imap: separate @continuation_request_exception from @exceptionshugo
Otherwise literal data will be sent even if NO response is returned because @exception is set to nil in receive_responses. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58844 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-22erb.rb: Skip creating regexpk0kubun
if stags and etags are not changed from default. :putobject insn (of regexp) will be used instead of :toregexp insn. This means that the regexp won't be compiled for every `SimpleScanner#scan` call. It may not be a good idea to apply this kind of optimization for all cases. But I applied this because it is default scanner and used frequently and has relatively large impact for benchmark like this: * Before app_erb 1.023 * After app_erb 0.781 This commit fixes only the bottleneck of performance regression introduced in r53412. For maintainability, I won't fix other small regressions like additional overhead of method calls. [ruby-core:73820] [Bug #12074] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58842 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-21lib/net/protocol: clear short-lived read buffernormal
Using a parallel Net::HTTP downloader, this reduced memory usage from around 120MB to 50MB on my 32-bit x86 system. * lib/net/protocol.rb (rbuf_fill): clear temporary buffer Test script I used: require 'net/http' require 'uri' require 'digest/sha1' url = 'http://80x24.org/git-i-forgot-to-pack/objects/pack/pack-97b25a76c03b489d4cbbd85b12d0e1ad28717e55.idx' uri = URI(url) use_ssl = "https" == uri.scheme thrs = 30.times.map do Thread.start do cur = Thread.current.object_id Net::HTTP.start(uri.host, uri.port, use_ssl: use_ssl) do |http| req = Net::HTTP::Get.new(uri) http.request(req) do |res| dig = Digest::SHA1.new res.read_body do |buf| dig.update(buf) #buf.clear # most Ruby programmers don't do this :< end warn "#{Time.now} #{cur} #{dig.hexdigest}\n" end end :done end end p thrs.map(&:value) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58840 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-21Remove redundant square bracketskazu
Use character class directly instead of character class in character class. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58827 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Allow trimming CR in all trim_modesk0kubun
to unify a behavior with r58823 and r58825. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58826 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Allow explicit trimming carriage returnk0kubun
when trim_mode is "-", for Windows environments. [ruby-core:39625] [Bug #5339] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58825 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Allow trimming carriage returnk0kubun
when trim_mode is "<>", for Windows environments. [Bug #11464] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Prevent potential unexpected rescuek0kubun
of LoadError in some method calls, not from `require "strscan"`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58822 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20erb.rb: Drop unused scanner implementationk0kubun
Original `SimpleScanner` was used only in tests. Since `SimpleScanner` and `SimpleScanner2` work in the same way, I want to drop the one which can't be used in a normal situation. The only difference was `SimpleScanner` can be loaded without strscan dependency but I think there's no situation that strscan is unavailable because it's a standard library. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58819 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20prime.rb: remove alias after timeout teststomar
* test/test_prime.rb: remove alias after timeout test. * lib/prime.rb: fix typo. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58813 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-20lib/prime: Fix primality of some large integers [#13492].marcandre
* lib/prime.rb: Use accurate sqrt to insure all factors are tested. Patch by Marcus Stollsteimer. * test/test_prime.rb: Adapt test for timeout git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58809 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Merge gemspec from ruby/fileutils.hsbt
* Replaced homepage option to source code location as github. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58808 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Define classes for r58800naruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58803 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Net::HTTP::STATUS_CODES is added as HTTP Status Code Repository [Misc #12935]naruse
Note that 418 I'm a teapot doesn't exist because RFC 2324 and RFC 7168 are not registered in IANA repository. https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58801 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Add more HTTP status classesnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58800 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19Net::HTTP#start now pass :ENV to p_addr by default [Bug #13351]naruse
To avoid this, pass nil explicitly. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58798 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19tempfile.rb: do not call File.identical? on closed streamnobu
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58794 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19* remove trailing spaces.svn
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58793 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19net/imap: Net::IMAP#append should not block when NO response is receivedshugo
[ruby-dev:50129] [Bug#13579] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58792 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-19tempfile.rb: remove in Tempfile.createnobu
* lib/tempfile.rb (Tempfile.create): should not fail even if the temporary file has been removed in the block, just ignore. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-18Improve CSV parsing performance.hsbt
Patch by @joshpencheon (Josh Pencheon) [fix GH-1607] #### benchmark-ips results ``` trunk: Warming up -------------------------------------- 4.000 i/100ms Calculating ------------------------------------- 39.661 (±10.1%) i/s - 2.352k in 60.034781s with-patch: Warming up -------------------------------------- 5.000 i/100ms Calculating ------------------------------------- 60.521 (± 9.9%) i/s - 3.595k in 60.047157s ``` #### memory_profiler resuts ``` trunk: allocated memory by class ----------------------------------- 35588490 String 7454320 Array 294000 MatchData 37340 Regexp 11840 Hash 2400 CSV 1600 Proc 1280 Method 800 StringIO with-patch: allocated memory by class ----------------------------------- 18788490 String 3454320 Array 294000 MatchData 37340 Regexp 11840 Hash 2400 CSV 1600 Proc 1280 Method 800 StringIO ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58777 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-17cgi/util.rb: Don't escape tilde in #escapek0kubun
to make it compatible with ERB::Util.url_encode. ext/cgi/escape/escape.c: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58773 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-17erb.rb: Don't encode tilde in #url_encodek0kubun
Based on patch by madeofcode (Mark Dodwell). [ruby-core:46168] [Bug #6696] [Fix GH-54] `~` is a unreserved character. https://tools.ietf.org/html/rfc3986#section-2.3 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58772 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-17Optimize CSV#shift.hsbt
[Bug #12373][ruby-core:75462] Patch by Yuki Kurihara. Benchmark: ``` Warming up -------------------------------------- csv_shift 1.000 i/100ms new_csv_shift 1.000 i/100ms Calculating ------------------------------------- csv_shift 1.192 (± 0.0%) i/s - 6.000 in 5.034250s new_csv_shift 1.527 (± 0.0%) i/s - 8.000 in 5.243446s Comparison: new_csv_shift: 1.5 i/s csv_shift: 1.2 i/s - 1.28x slower ``` git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-16Strip punctuation from CSV headers in symbol converter.hsbt
Patch by @cllns. [Fix GH-957] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58744 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-16Added accessor of original line when parsing.hsbt
[Feature #11865][ruby-core:72452][fix GH-1170] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58743 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-16fix tempfile leaks on Windowsnobu
* lib/rubygems/ext/ext_conf_builder.rb (build): needs to close before unlink on Windows. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58741 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-15refresh Gem at the end of `teardown`.ko1
* lib/rubygems/test_case.rb (teardown): call `Gem::refresh()` at the end of `teardown`. On parallel test sometimes fails test process. The reason is: (1) previous tests remains `Gem::Specification@@stubs` value which points to temporary directories and the directories are removed by `teardown` method of previous test. (2) `require 'rubygems/gem_runner'` in `test_gem_gem_runner.rb` tries to require test utility file. However, with strange `@@stubs` RubyGems tries to load specification from removed directory. `StubSpecification#to_spec` returns `nil` and error will occur. The solution this patch employs is to refresh all of parameters includes `Gem::Specification@@stubs` by `Gem::refresh()`. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58736 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-15erb.rb: Use String#<< instead of #concatk0kubun
to optimize String concatenation on rendering. [fix GH-1612] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58735 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-12net/imap: Revert read_tiemout in r58549.shugo
get_response is called in a receiver thread, so there may be no pending commands when get_response is called. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-11net/imap: Net::IMAP#disconnect need not do anything if already disconnectedshugo
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58663 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-10lib/uri/generic.rb: fix typosstomar
* lib/uri/generic.rb: [DOC] fix typos in URI::Generic#== docs. Patch by Alyssa Ross (alyssais). [Fix GH-1604] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58655 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-10confirm current process equals to gemhome's pidnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58648 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09dump stub specifications if nilnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58642 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09add explanations about status of module UnicodeNormalizeduerst
In lib/unicode_normalize/normalize.rb, add explanations and clarifications about the status of the files and the module. [ci skip] This is in response to discussions at https://github.com/ruby/spec/pull/433 and https://bugs.ruby-lang.org/issues/5481#note-58. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58617 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-09Add one more guard to avoid mixing nil into latest_specsnaruse
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58616 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-06delete lib/unicode_normalize.rb, because no longer neededduerst
(all content has been moved to string.c) git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58578 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-06share `@@accept_charset`nobu
* lib/cgi/{core,util}.rb: include CGI::Util not only extending, to share `@@accept_charset` class variable, so that it is always accessible. [ruby-core:80986] [Bug #13539] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58576 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2017-05-04move definition of String#unicode_normalized? to C to make sure it is documentedduerst
* lib/unicode_normalize.rb: Remove definition of String#unicode_normalized? (including documentation). Leave a comment explaining that the file is now empty. * string.c: Define String#unicode_normalized? in rb_str_unicode_normalized_p in C, (including documentation) * lib/unicode_normalize/normalize.rb: Remove (re)definition of String#unicode_normalized? to avoid warnings (when $VERBOSE==true) and problems when String is frozen git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58555 b2dd03c8-39d4-4d8f-98ff-823fe69b080e