1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

strscan.c: make string directly

* ext/strscan/strscan.c (inspect1): extract intermediate string from
  the buffer directly, like as inspect2.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@44591 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2014-01-14 02:48:07 +00:00
parent ab4e0ab458
commit 747e3c73e0

View file

@ -1186,20 +1186,20 @@ strscan_inspect(VALUE self)
static VALUE
inspect1(struct strscanner *p)
{
char buf[BUFSIZE];
char *bp = buf;
VALUE str;
long len;
if (p->curr == 0) return rb_str_new2("");
if (p->curr > INSPECT_LENGTH) {
strcpy(bp, "..."); bp += 3;
str = rb_str_new_cstr("...");
len = INSPECT_LENGTH;
}
else {
str = rb_str_new(0, 0);
len = p->curr;
}
memcpy(bp, CURPTR(p) - len, len); bp += len;
return rb_str_dump(rb_str_new(buf, bp - buf));
rb_str_cat2(str, CURPTR(p) - len, len);
return rb_str_dump(str);
}
static VALUE