Commit bc23a5e9 authored by cremno's avatar cremno

remove `mrb_str_buf_cat`

It does the same as `mrb_str_cat`.
parent db6e8682
...@@ -66,7 +66,6 @@ mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len ...@@ -66,7 +66,6 @@ mrb_value mrb_str_substr(mrb_state *mrb, mrb_value str, mrb_int beg, mrb_int len
mrb_value mrb_string_type(mrb_state *mrb, mrb_value str); mrb_value mrb_string_type(mrb_state *mrb, mrb_value str);
mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str); mrb_value mrb_check_string_type(mrb_state *mrb, mrb_value str);
mrb_value mrb_str_buf_new(mrb_state *mrb, size_t capa); mrb_value mrb_str_buf_new(mrb_state *mrb, size_t capa);
mrb_value mrb_str_buf_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len);
char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr); char *mrb_string_value_cstr(mrb_state *mrb, mrb_value *ptr);
char *mrb_string_value_ptr(mrb_state *mrb, mrb_value ptr); char *mrb_string_value_ptr(mrb_state *mrb, mrb_value ptr);
...@@ -96,6 +95,12 @@ mrb_str_cat2(mrb_state *mrb, mrb_value str, const char *ptr) { ...@@ -96,6 +95,12 @@ mrb_str_cat2(mrb_state *mrb, mrb_value str, const char *ptr) {
return mrb_str_cat_cstr(mrb, str, ptr); return mrb_str_cat_cstr(mrb, str, ptr);
} }
static inline mrb_value
mrb_str_buf_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len)
{
return mrb_str_cat(mrb, str, ptr, len);
}
#if defined(__cplusplus) #if defined(__cplusplus)
} /* extern "C" { */ } /* extern "C" { */
#endif #endif
......
...@@ -955,7 +955,7 @@ join_ary(mrb_state *mrb, mrb_value ary, mrb_value sep, mrb_value list) ...@@ -955,7 +955,7 @@ join_ary(mrb_state *mrb, mrb_value ary, mrb_value sep, mrb_value list)
for (i=0; i<RARRAY_LEN(ary); i++) { for (i=0; i<RARRAY_LEN(ary); i++) {
if (i > 0 && !mrb_nil_p(sep)) { if (i > 0 && !mrb_nil_p(sep)) {
mrb_str_buf_cat(mrb, result, RSTRING_PTR(sep), RSTRING_LEN(sep)); mrb_str_buf_append(mrb, result, sep);
} }
val = RARRAY_PTR(ary)[i]; val = RARRAY_PTR(ary)[i];
...@@ -967,7 +967,7 @@ join_ary(mrb_state *mrb, mrb_value ary, mrb_value sep, mrb_value list) ...@@ -967,7 +967,7 @@ join_ary(mrb_state *mrb, mrb_value ary, mrb_value sep, mrb_value list)
case MRB_TT_STRING: case MRB_TT_STRING:
str_join: str_join:
mrb_str_buf_cat(mrb, result, RSTRING_PTR(val), RSTRING_LEN(val)); mrb_str_buf_append(mrb, result, val);
break; break;
default: default:
......
...@@ -277,14 +277,6 @@ str_buf_cat(mrb_state *mrb, struct RString *s, const char *ptr, size_t len) ...@@ -277,14 +277,6 @@ str_buf_cat(mrb_state *mrb, struct RString *s, const char *ptr, size_t len)
STR_PTR(s)[total] = '\0'; /* sentinel */ STR_PTR(s)[total] = '\0'; /* sentinel */
} }
mrb_value
mrb_str_buf_cat(mrb_state *mrb, mrb_value str, const char *ptr, size_t len)
{
if (len == 0) return str;
str_buf_cat(mrb, mrb_str_ptr(str), ptr, len);
return str;
}
mrb_value mrb_value
mrb_str_new(mrb_state *mrb, const char *p, size_t len) mrb_str_new(mrb_state *mrb, const char *p, size_t len)
{ {
...@@ -2518,12 +2510,12 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str) ...@@ -2518,12 +2510,12 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str)
c = *p; c = *p;
if (c == '"'|| c == '\\' || (c == '#' && IS_EVSTR(p, pend))) { if (c == '"'|| c == '\\' || (c == '#' && IS_EVSTR(p, pend))) {
buf[0] = '\\'; buf[1] = c; buf[0] = '\\'; buf[1] = c;
mrb_str_buf_cat(mrb, result, buf, 2); mrb_str_cat(mrb, result, buf, 2);
continue; continue;
} }
if (ISPRINT(c)) { if (ISPRINT(c)) {
buf[0] = c; buf[0] = c;
mrb_str_buf_cat(mrb, result, buf, 1); mrb_str_cat(mrb, result, buf, 1);
continue; continue;
} }
switch (c) { switch (c) {
...@@ -2540,7 +2532,7 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str) ...@@ -2540,7 +2532,7 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str)
if (cc) { if (cc) {
buf[0] = '\\'; buf[0] = '\\';
buf[1] = (char)cc; buf[1] = (char)cc;
mrb_str_buf_cat(mrb, result, buf, 2); mrb_str_cat(mrb, result, buf, 2);
continue; continue;
} }
else { else {
...@@ -2548,7 +2540,7 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str) ...@@ -2548,7 +2540,7 @@ mrb_str_inspect(mrb_state *mrb, mrb_value str)
buf[3] = '0' + c % 8; c /= 8; buf[3] = '0' + c % 8; c /= 8;
buf[2] = '0' + c % 8; c /= 8; buf[2] = '0' + c % 8; c /= 8;
buf[1] = '0' + c % 8; buf[1] = '0' + c % 8;
mrb_str_buf_cat(mrb, result, buf, 4); mrb_str_cat(mrb, result, buf, 4);
continue; continue;
} }
} }
......
...@@ -564,8 +564,8 @@ localjump_error(mrb_state *mrb, localjump_error_kind kind) ...@@ -564,8 +564,8 @@ localjump_error(mrb_state *mrb, localjump_error_kind kind)
mrb_value exc; mrb_value exc;
msg = mrb_str_buf_new(mrb, sizeof(lead) + 7); msg = mrb_str_buf_new(mrb, sizeof(lead) + 7);
mrb_str_buf_cat(mrb, msg, lead, sizeof(lead) - 1); mrb_str_cat(mrb, msg, lead, sizeof(lead) - 1);
mrb_str_buf_cat(mrb, msg, kind_str[kind], kind_str_len[kind]); mrb_str_cat(mrb, msg, kind_str[kind], kind_str_len[kind]);
exc = mrb_exc_new_str(mrb, E_LOCALJUMP_ERROR, msg); exc = mrb_exc_new_str(mrb, E_LOCALJUMP_ERROR, msg);
mrb->exc = mrb_obj_ptr(exc); mrb->exc = mrb_obj_ptr(exc);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment