mirror of
https://github.com/ruby/ruby.git
synced 2025-09-15 16:44:01 +02:00
delay `exception: false' checks for minor speedup
Delay hash lookups until we are about to hit an exception. This gives a minor speedup ratio of 2-3% in the new bm_io_nonblock_noex benchmark as well as reducing code. * benchmark/bm_io_nonblock_noex.rb: new benchmark * ext/openssl/ossl_ssl.c (no_exception_p): new function (ossl_start_ssl): adjust for no_exception_p (ossl_ssl_connect): adjust ossl_start_ssl call (ossl_ssl_connect_nonblock): ditto (ossl_ssl_accept): ditto (ossl_ssl_accept_nonblock): ditto (ossl_ssl_read_internal): adjust for no_exception_p (ossl_ssl_write_internal): ditto (ossl_ssl_write): adjust ossl_write_internal call (ossl_ssl_write_nonblock): ditto * ext/stringio/stringio.c (strio_read_nonblock): delay exception check * io.c (no_exception_p): new function (io_getpartial): call no_exception_p (io_readpartial): adjust for io_getpartial (get_kwargs_exception): remove (io_read_nonblock): adjust for io_getpartial, check no_exception_p on EOF (io_write_nonblock): call no_exception_p (rb_io_write_nonblock): do not check `exception: false' (argf_getpartial): adjust for io_getpartial [ruby-core:69778] [Feature #11318] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51113 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
79d757b147
commit
df4e282eeb
5 changed files with 104 additions and 77 deletions
|
@ -1359,20 +1359,17 @@ static VALUE
|
|||
strio_read_nonblock(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE opts = Qnil, val;
|
||||
int no_exception = 0;
|
||||
|
||||
rb_scan_args(argc, argv, "11:", NULL, NULL, &opts);
|
||||
|
||||
if (!NIL_P(opts)) {
|
||||
argc--;
|
||||
|
||||
if (Qfalse == rb_hash_aref(opts, sym_exception))
|
||||
no_exception = 1;
|
||||
}
|
||||
|
||||
val = strio_read(argc, argv, self);
|
||||
if (NIL_P(val)) {
|
||||
if (no_exception)
|
||||
if (!NIL_P(opts) &&
|
||||
rb_hash_lookup2(opts, sym_exception, Qundef) == Qfalse)
|
||||
return Qnil;
|
||||
else
|
||||
rb_eof_error();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue