diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-31 10:47:44 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-08-31 10:47:44 +0000 |
commit | 54af80844fbcf132f85e9275673eaa66b72da996 (patch) | |
tree | 4509d254ff81222c7b4db1b34cbcc377c2311e54 /bignum.c | |
parent | 25c50cd193d89ad0737219142bab191f12b8abe8 (diff) | |
download | ruby-54af80844fbcf132f85e9275673eaa66b72da996.tar.gz |
* ruby.h (struct RString): embed small strings.
(RSTRING_LEN): defined for accessing string members.
(RSTRING_PTR): ditto.
* string.c: use RSTRING_LEN and RSTRING_PTR.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10810 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'bignum.c')
-rw-r--r-- | bignum.c | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -494,10 +494,10 @@ rb_str_to_inum(VALUE str, int base, int badcheck) s = StringValueCStr(str); } else { - s = RSTRING(str)->ptr; + s = RSTRING_PTR(str); } if (s) { - len = RSTRING(str)->len; + len = RSTRING_LEN(str); if (s[len]) { /* no sentinel somehow */ char *p = ALLOCA_N(char, len+1); @@ -631,7 +631,7 @@ rb_big2str(VALUE x, int base) t = rb_big_clone(x); ds = BDIGITS(t); ss = rb_str_new(0, j); - s = RSTRING(ss)->ptr; + s = RSTRING_PTR(ss); s[0] = RBIGNUM(x)->sign ? '+' : '-'; while (i && j) { @@ -653,9 +653,9 @@ rb_big2str(VALUE x, int base) } } while (s[j] == '0') j++; - RSTRING(ss)->len -= RBIGNUM(x)->sign?j:j-1; - memmove(RBIGNUM(x)->sign?s:s+1, s+j, RSTRING(ss)->len); - s[RSTRING(ss)->len] = '\0'; + i = RSTRING_LEN(ss)-(RBIGNUM(x)->sign?j:j-1); + memmove(RBIGNUM(x)->sign?s:s+1, s+j, i); + rb_str_set_len(ss, i); return ss; } |