* lib/optparse.rb: try Float() and Integer() instead of eval,
which does too much things.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59312 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Previously if the input started with a '0' then it will be converted
as octal even though it has been specified as a decimal. This commit
forces the number to be interpreted as a decimal.
[ruby-core:81927] [Bug #13722] [Fix GH-1665]
Author: william <william.mccumstie@outlook.com>
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59273 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Also, error out if --ssl-private-key option is not given, since
specifying only the certificate makes no sense. [Feature #13714]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59268 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/un.rb: add https support. based on the patch by Flavio
Castelli <flavio@castelli.name> in [ruby-core:81901].
[Feature #13714]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59265 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/delegate.rb (eql?): Delegate to `eql?` of the inner object.
based on the patch by giginet <giginet.net@gmail.com>.
[ruby-core:76950] [Bug #12684]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59167 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
* lib/shell/system-command.rb (SystemCommand#initialize):
`def_e2message` wraps error message, but does not define new exception
* test/shell/test_command_processor.rb: add a test
This patch is authored by Kenichi Kamiya <kachick1@gmail.com>
close#1657
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59145 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Added following gemspecs.
* extensions: date, dbm, etc, fiddle, gdbm, sdbm, stringio, strscan, zlib
* pure ruby libraries: cmath, csv, fileutils, scanf, webrick
psych and rdoc is out of scope of this commit. I will merge after
upstream was change to `frozen_string_literal: true`.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59115 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
There actually are some libraries that requires 'irb' such as byebug, and when
'irb' is required, it requires irb/src_encoding.rb, then it defines the toplevel
default_src_encoding method that is visible from anywhere in the end users' apps.
Here's a quick oneliner that shows what's happening.
% ruby -rpry-byebug -e 'p private_methods(false)'
[:include, :using, :define_method, :public, :private, :DelegateClass, :default_src_encoding]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@59090 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
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
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
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
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
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
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
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
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
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
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
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
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
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
* 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
* 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
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
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
* 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
* 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
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