mirror of
https://github.com/ruby/ruby.git
synced 2025-09-20 02:53:57 +02:00
merge revision(s) 3b567eb491
: [Backport #19459]
[Bug #19459] Remove unnecessary always-true checks (#7362) `length` is a required argument for `IO::Buffer#read` and `IO::Buffer#write` methods, and `argc` is already checked with `rb_check_arity`. Also fix the call-seq of `IO::Buffer#read`. --- io_buffer.c | 24 +++++++----------------- 1 file changed, 7 insertions(+), 17 deletions(-)
This commit is contained in:
parent
4e4a4e42b2
commit
db28f7003f
2 changed files with 8 additions and 18 deletions
16
io_buffer.c
16
io_buffer.c
|
@ -2415,13 +2415,11 @@ rb_io_buffer_read(VALUE self, VALUE io, size_t length, size_t offset)
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq: read(io, [length, [offset]]) -> read length or -errno
|
* call-seq: read(io, length, [offset]) -> read length or -errno
|
||||||
*
|
*
|
||||||
* Read at most +length+ bytes from +io+ into the buffer, starting at
|
* Read at most +length+ bytes from +io+ into the buffer, starting at
|
||||||
* +offset+. If an error occurs, return <tt>-errno</tt>.
|
* +offset+. If an error occurs, return <tt>-errno</tt>.
|
||||||
*
|
*
|
||||||
* If +length+ is not given, read until the end of the buffer.
|
|
||||||
*
|
|
||||||
* If +offset+ is not given, read from the beginning of the buffer.
|
* If +offset+ is not given, read from the beginning of the buffer.
|
||||||
*
|
*
|
||||||
* If +length+ is 0, read nothing.
|
* If +length+ is 0, read nothing.
|
||||||
|
@ -2447,14 +2445,10 @@ io_buffer_read(int argc, VALUE *argv, VALUE self)
|
||||||
|
|
||||||
VALUE io = argv[0];
|
VALUE io = argv[0];
|
||||||
|
|
||||||
size_t length;
|
|
||||||
if (argc >= 2) {
|
|
||||||
if (rb_int_negative_p(argv[1])) {
|
if (rb_int_negative_p(argv[1])) {
|
||||||
rb_raise(rb_eArgError, "Length can't be negative!");
|
rb_raise(rb_eArgError, "Length can't be negative!");
|
||||||
}
|
}
|
||||||
|
size_t length = NUM2SIZET(argv[1]);
|
||||||
length = NUM2SIZET(argv[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
if (argc >= 3) {
|
if (argc >= 3) {
|
||||||
|
@ -2660,14 +2654,10 @@ io_buffer_write(int argc, VALUE *argv, VALUE self)
|
||||||
|
|
||||||
VALUE io = argv[0];
|
VALUE io = argv[0];
|
||||||
|
|
||||||
size_t length;
|
|
||||||
if (argc >= 2) {
|
|
||||||
if (rb_int_negative_p(argv[1])) {
|
if (rb_int_negative_p(argv[1])) {
|
||||||
rb_raise(rb_eArgError, "Length can't be negative!");
|
rb_raise(rb_eArgError, "Length can't be negative!");
|
||||||
}
|
}
|
||||||
|
size_t length = NUM2SIZET(argv[1]);
|
||||||
length = NUM2SIZET(argv[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
if (argc >= 3) {
|
if (argc >= 3) {
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
# define RUBY_VERSION_MINOR RUBY_API_VERSION_MINOR
|
||||||
#define RUBY_VERSION_TEENY 1
|
#define RUBY_VERSION_TEENY 1
|
||||||
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
#define RUBY_RELEASE_DATE RUBY_RELEASE_YEAR_STR"-"RUBY_RELEASE_MONTH_STR"-"RUBY_RELEASE_DAY_STR
|
||||||
#define RUBY_PATCHLEVEL 38
|
#define RUBY_PATCHLEVEL 39
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
#include "ruby/internal/abi.h"
|
#include "ruby/internal/abi.h"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue