diff options
| author | Masaki Muranaka <[email protected]> | 2012-06-21 11:45:55 +0900 |
|---|---|---|
| committer | Masaki Muranaka <[email protected]> | 2012-06-21 11:45:55 +0900 |
| commit | 0c5b704de355d021f73af72ff4050485fe4203ec (patch) | |
| tree | 1a560c6d53f205035307c9628faa8867ebb1bdce | |
| parent | 750a639eab6e0c5615cd7651c1ab4215a8247ef7 (diff) | |
| download | mruby-0c5b704de355d021f73af72ff4050485fe4203ec.tar.gz mruby-0c5b704de355d021f73af72ff4050485fe4203ec.zip | |
Remove strlen(). We can use sizeof() of char array because sizeof(char) is always 1 (ISO C99).
| -rw-r--r-- | src/array.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/array.c b/src/array.c index 3b42abc74..ca111bc0e 100644 --- a/src/array.c +++ b/src/array.c @@ -880,9 +880,9 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list) { int i; mrb_value s, arystr; - char *head = "["; - char *sep = ", "; - char *tail = "]"; + char head[] = { '[' }; + char sep[] = { ',', ' ' }; + char tail[] = { ']' }; /* check recursive */ for(i=0; i<RARRAY_LEN(list); i++) { @@ -894,13 +894,13 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list) mrb_ary_push(mrb, list, ary); arystr = mrb_str_buf_new(mrb, 64); - mrb_str_buf_cat(mrb, arystr, head, strlen(head)); + mrb_str_buf_cat(mrb, arystr, head, sizeof(head)); for(i=0; i<RARRAY_LEN(ary); i++) { int ai = mrb_gc_arena_save(mrb); if (i > 0) { - mrb_str_buf_cat(mrb, arystr, sep, strlen(sep)); + mrb_str_buf_cat(mrb, arystr, sep, sizeof(sep)); } if (mrb_type(RARRAY_PTR(ary)[i]) == MRB_TT_ARRAY) { s = inspect_ary(mrb, RARRAY_PTR(ary)[i], list); @@ -911,7 +911,7 @@ inspect_ary(mrb_state *mrb, mrb_value ary, mrb_value list) mrb_gc_arena_restore(mrb, ai); } - mrb_str_buf_cat(mrb, arystr, tail, strlen(tail)); + mrb_str_buf_cat(mrb, arystr, tail, sizeof(tail)); mrb_ary_pop(mrb, list); return arystr; |
