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:
parent
ab4e0ab458
commit
747e3c73e0
1 changed files with 7 additions and 7 deletions
|
@ -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;
|
||||
len = INSPECT_LENGTH;
|
||||
str = rb_str_new_cstr("...");
|
||||
len = INSPECT_LENGTH;
|
||||
}
|
||||
else {
|
||||
len = p->curr;
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue