aboutsummaryrefslogtreecommitdiffstats
path: root/array.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-04 08:23:10 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-04-04 08:23:10 +0000
commitfd7dc1b6eaf13be7e8270558d12e17864a7446b1 (patch)
treed47456f2cd32c729e45bfdb101f0613acfbc54f9 /array.c
parent5e2c39ed226d084a340c6f860344062bd32d56b9 (diff)
downloadruby-fd7dc1b6eaf13be7e8270558d12e17864a7446b1.tar.gz
reduce overhead of TYPE
* array.c (ary_join_1): reduce overhead of TYPE(). * eval.c (rb_frozen_class_p, rb_mod_{append,prepend}_features): ditto. * string.c (rb_to_id): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40105 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'array.c')
-rw-r--r--array.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/array.c b/array.c
index c0f6dd8cb6..76a3a6279d 100644
--- a/array.c
+++ b/array.c
@@ -1839,13 +1839,12 @@ ary_join_1(VALUE obj, VALUE ary, VALUE sep, long i, VALUE result, int *first)
rb_str_buf_append(result, sep);
val = RARRAY_PTR(ary)[i];
- switch (TYPE(val)) {
- case T_STRING:
+ if (RB_TYPE_P(val, T_STRING)) {
str_join:
rb_str_buf_append(result, val);
*first = FALSE;
- break;
- case T_ARRAY:
+ }
+ else if (RB_TYPE_P(val, T_ARRAY)) {
obj = val;
ary_join:
if (val == ary) {
@@ -1860,8 +1859,8 @@ ary_join_1(VALUE obj, VALUE ary, VALUE sep, long i, VALUE result, int *first)
args[3] = (VALUE)first;
rb_exec_recursive(recursive_join, obj, (VALUE)args);
}
- break;
- default:
+ }
+ else {
tmp = rb_check_string_type(val);
if (!NIL_P(tmp)) {
val = tmp;