mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* io.c (swallow): small optimize.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6f3791f465
commit
44d8ab7203
1 changed files with 4 additions and 4 deletions
8
io.c
8
io.c
|
@ -2294,23 +2294,23 @@ static inline int
|
|||
swallow(rb_io_t *fptr, int term)
|
||||
{
|
||||
if (NEED_READCONV(fptr)) {
|
||||
rb_encoding *enc = io_read_encoding(fptr);
|
||||
int needconv = rb_enc_mbminlen(enc) != 1;
|
||||
VALUE v;
|
||||
make_readconv(fptr, 0);
|
||||
do {
|
||||
size_t cnt;
|
||||
while ((cnt = READ_CHAR_PENDING_COUNT(fptr)) > 0) {
|
||||
const char *p = READ_CHAR_PENDING_PTR(fptr);
|
||||
rb_encoding *enc = io_read_encoding(fptr);
|
||||
int i;
|
||||
if (rb_enc_mbminlen(enc) == 1) {
|
||||
if (needconv) {
|
||||
if (*p != term) return TRUE;
|
||||
while (--i && *++p == term);
|
||||
}
|
||||
else {
|
||||
const char *e = p + cnt;
|
||||
if (rb_enc_ascget(p, e, &i, enc) != term) return TRUE;
|
||||
while ((p += i) < e && rb_enc_ascget(p, e, &i, enc) == term)
|
||||
;
|
||||
while ((p += i) < e && rb_enc_ascget(p, e, &i, enc) == term);
|
||||
i = (int)(e - p);
|
||||
}
|
||||
io_shift_cbuf(fptr, (int)cnt - i, NULL);
|
||||
|
|
Loading…
Add table
Reference in a new issue