* ext/stringio/stringio.c (check_modifiable): performance
improvement. avoid calling rb_str_modify() twice. * ext/stringio/stringio.c (strio_ungetc): ditto. * ext/stringio/stringio.c (strio_putc): ditto. * ext/stringio/stringio.c (strio_write): ditto, and use rb_str_cat() as possible. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@2345 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
f240fc637c
commit
e223518948
12
ChangeLog
12
ChangeLog
@ -1,3 +1,15 @@
|
|||||||
|
Tue Apr 9 12:44:59 2002 Nobuyoshi Nakada <nobu.nakada@nifty.ne.jp>
|
||||||
|
|
||||||
|
* ext/stringio/stringio.c (check_modifiable): performance
|
||||||
|
improvement. avoid calling rb_str_modify() twice.
|
||||||
|
|
||||||
|
* ext/stringio/stringio.c (strio_ungetc): ditto.
|
||||||
|
|
||||||
|
* ext/stringio/stringio.c (strio_putc): ditto.
|
||||||
|
|
||||||
|
* ext/stringio/stringio.c (strio_write): ditto, and use
|
||||||
|
rb_str_cat() as possible.
|
||||||
|
|
||||||
Tue Apr 9 05:17:48 2002 Akinori MUSHA <knu@iDaemons.org>
|
Tue Apr 9 05:17:48 2002 Akinori MUSHA <knu@iDaemons.org>
|
||||||
|
|
||||||
* re.c (match_select): fix index references and make
|
* re.c (match_select): fix index references and make
|
||||||
|
@ -125,7 +125,6 @@ check_modifiable(ptr)
|
|||||||
if (OBJ_FROZEN(ptr->string)) {
|
if (OBJ_FROZEN(ptr->string)) {
|
||||||
rb_raise(rb_eIOError, "not modifiable string");
|
rb_raise(rb_eIOError, "not modifiable string");
|
||||||
}
|
}
|
||||||
rb_str_modify(ptr->string);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static VALUE strio_s_allocate _((VALUE));
|
static VALUE strio_s_allocate _((VALUE));
|
||||||
@ -548,6 +547,7 @@ strio_ungetc(self, ch)
|
|||||||
if ((unsigned char)RSTRING(ptr->string)->ptr[--ptr->pos] !=
|
if ((unsigned char)RSTRING(ptr->string)->ptr[--ptr->pos] !=
|
||||||
(unsigned char)cc) {
|
(unsigned char)cc) {
|
||||||
check_modifiable(ptr);
|
check_modifiable(ptr);
|
||||||
|
rb_str_modify(ptr->string);
|
||||||
RSTRING(ptr->string)->ptr[ptr->pos] = cc;
|
RSTRING(ptr->string)->ptr[ptr->pos] = cc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -740,10 +740,18 @@ strio_write(self, str)
|
|||||||
if (ptr->flags & STRIO_APPEND) {
|
if (ptr->flags & STRIO_APPEND) {
|
||||||
ptr->pos = RSTRING(ptr->string)->len;
|
ptr->pos = RSTRING(ptr->string)->len;
|
||||||
}
|
}
|
||||||
if (ptr->pos + len > RSTRING(ptr->string)->len) {
|
if (ptr->pos == RSTRING(ptr->string)->len) {
|
||||||
rb_str_resize(ptr->string, ptr->pos + len);
|
rb_str_cat(ptr->string, RSTRING(str)->ptr, len);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (ptr->pos + len > RSTRING(ptr->string)->len) {
|
||||||
|
rb_str_resize(ptr->string, ptr->pos + len);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
rb_str_modify(ptr->string);
|
||||||
|
}
|
||||||
|
rb_str_update(ptr->string, ptr->pos, len, str);
|
||||||
}
|
}
|
||||||
rb_str_update(ptr->string, ptr->pos, len, str);
|
|
||||||
ptr->pos += len;
|
ptr->pos += len;
|
||||||
return LONG2NUM(len);
|
return LONG2NUM(len);
|
||||||
}
|
}
|
||||||
@ -768,6 +776,9 @@ strio_putc(self, ch)
|
|||||||
if (ptr->pos >= RSTRING(ptr->string)->len) {
|
if (ptr->pos >= RSTRING(ptr->string)->len) {
|
||||||
rb_str_resize(ptr->string, ptr->pos + 1);
|
rb_str_resize(ptr->string, ptr->pos + 1);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
rb_str_modify(ptr->string);
|
||||||
|
}
|
||||||
RSTRING(ptr->string)->ptr[ptr->pos++] = c;
|
RSTRING(ptr->string)->ptr[ptr->pos++] = c;
|
||||||
return ch;
|
return ch;
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#define RUBY_VERSION "1.7.2"
|
#define RUBY_VERSION "1.7.2"
|
||||||
#define RUBY_RELEASE_DATE "2002-04-08"
|
#define RUBY_RELEASE_DATE "2002-04-09"
|
||||||
#define RUBY_VERSION_CODE 172
|
#define RUBY_VERSION_CODE 172
|
||||||
#define RUBY_RELEASE_CODE 20020408
|
#define RUBY_RELEASE_CODE 20020409
|
||||||
|
Loading…
x
Reference in New Issue
Block a user