summaryrefslogtreecommitdiffstats
path: root/string.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-23 11:18:07 +0000
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-02-23 11:18:07 +0000
commit4d1b41160cf8115d0a4041fee3e6e1ee878268eb (patch)
treee8fa720ef7279b9004ca1bf50d7a583553348805 /string.c
parentfab8a5553f3e37e9e536db6fbea487a05b8140e8 (diff)
downloadruby-4d1b41160cf8115d0a4041fee3e6e1ee878268eb.tar.gz
ruby-4d1b41160cf8115d0a4041fee3e6e1ee878268eb.tar.xz
ruby-4d1b41160cf8115d0a4041fee3e6e1ee878268eb.zip
* string.c (str_sublen): removed.
* string.c (rb_str_reverse, rb_str_reverse_bang): use single_byte_optimizable. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@15583 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'string.c')
-rw-r--r--string.c18
1 files changed, 6 insertions, 12 deletions
diff --git a/string.c b/string.c
index d798e00e1..596459d91 100644
--- a/string.c
+++ b/string.c
@@ -1165,23 +1165,17 @@ str_utf8_offset(const char *p, const char *e, int nth)
}
#endif
-static long
-str_sublen(VALUE str, long pos, rb_encoding *enc)
+long
+rb_str_sublen(VALUE str, long pos)
{
- if (rb_enc_mbmaxlen(enc) == 1 || pos < 0)
+ if (single_byte_optimizable(str) || pos < 0)
return pos;
else {
char *p = RSTRING_PTR(str);
- return rb_enc_strlen(p, p + pos, enc);
+ return rb_enc_strlen(p, p + pos, STR_ENC_GET(str));
}
}
-int
-rb_str_sublen(VALUE str, int len)
-{
- return str_sublen(str, len, STR_ENC_GET(str));
-}
-
VALUE
rb_str_subseq(VALUE str, long beg, long len)
{
@@ -3480,7 +3474,7 @@ rb_str_reverse(VALUE str)
p = RSTRING_END(obj);
if (RSTRING_LEN(str) > 1) {
- if (rb_enc_mbmaxlen(enc) == 1) {
+ if (single_byte_optimizable(str)) {
while (s < e) {
*--p = *s++;
}
@@ -3521,7 +3515,7 @@ rb_str_reverse_bang(VALUE str)
s = RSTRING_PTR(str);
e = RSTRING_END(str) - 1;
- if (rb_enc_mbmaxlen(enc) == 1) {
+ if (single_byte_optimizable(str)) {
while (s < e) {
c = *s;
*s++ = *e;