summaryrefslogtreecommitdiff
path: root/ext/tk/tkutil
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-05 01:09:17 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-05 01:09:17 +0000
commit57e2877e7b8257665f07f63aa37ed09f8fe78310 (patch)
tree1f9d2f407d43672c5a2fa4aaeaa8cfd1255b2f32 /ext/tk/tkutil
parenta015a01354d7f185eb794e3280c4168c2cb38100 (diff)
ext: use RARRAY_AREF
* ext/**/*.c: prefer RARRAY_AREF to indexing RARRAY_CONST_PTR. pointed out by hanmac. https://github.com/ruby/ruby/commit/3553a86#commitcomment-14187670 git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52453 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/tk/tkutil')
-rw-r--r--ext/tk/tkutil/tkutil.c52
1 files changed, 26 insertions, 26 deletions
diff --git a/ext/tk/tkutil/tkutil.c b/ext/tk/tkutil/tkutil.c
index f18fadfc7f..f6f0af1cd7 100644
--- a/ext/tk/tkutil/tkutil.c
+++ b/ext/tk/tkutil/tkutil.c
@@ -371,8 +371,8 @@ ary2list(ary, enc_flag, self)
/* size = RARRAY_LEN(ary); */
size = 0;
for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
- if (RB_TYPE_P(RARRAY_CONST_PTR(ary)[idx], T_HASH)) {
- size += 2 * RHASH_SIZE(RARRAY_CONST_PTR(ary)[idx]);
+ if (RB_TYPE_P(RARRAY_AREF(ary, idx), T_HASH)) {
+ size += 2 * RHASH_SIZE(RARRAY_AREF(ary, idx));
} else {
size++;
}
@@ -380,7 +380,7 @@ ary2list(ary, enc_flag, self)
dst = rb_ary_new2(size);
for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
- val = RARRAY_CONST_PTR(ary)[idx];
+ val = RARRAY_AREF(ary, idx);
str_val = Qnil;
switch(TYPE(val)) {
case T_ARRAY:
@@ -411,7 +411,7 @@ ary2list(ary, enc_flag, self)
}
size2 = RARRAY_LEN(val);
for(idx2 = 0; idx2 < size2; idx2++) {
- val2 = RARRAY_CONST_PTR(val)[idx2];
+ val2 = RARRAY_AREF(val, idx2);
switch(TYPE(val2)) {
case T_ARRAY:
str_val = ary2list(val2, enc_flag, self);
@@ -472,7 +472,7 @@ ary2list(ary, enc_flag, self)
if (RTEST(dst_enc) && !NIL_P(sys_enc)) {
for(idx = 0; idx < RARRAY_LEN(dst); idx++) {
- str_val = RARRAY_CONST_PTR(dst)[idx];
+ str_val = RARRAY_AREF(dst, idx);
if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
str_val = rb_funcall(self, ID_toUTF8, 1, str_val);
} else {
@@ -525,7 +525,7 @@ ary2list2(ary, enc_flag, self)
size = RARRAY_LEN(ary);
dst = rb_ary_new2(size);
for(idx = 0; idx < RARRAY_LEN(ary); idx++) {
- val = RARRAY_CONST_PTR(ary)[idx];
+ val = RARRAY_AREF(ary, idx);
str_val = Qnil;
switch(TYPE(val)) {
case T_ARRAY:
@@ -566,7 +566,7 @@ ary2list2(ary, enc_flag, self)
if (RTEST(dst_enc) && !NIL_P(sys_enc)) {
for(idx = 0; idx < RARRAY_LEN(dst); idx++) {
- str_val = RARRAY_CONST_PTR(dst)[idx];
+ str_val = RARRAY_AREF(dst, idx);
if (rb_obj_respond_to(self, ID_toUTF8, Qtrue)) {
str_val = rb_funcall(self, ID_toUTF8, 1, str_val);
} else {
@@ -608,23 +608,23 @@ assoc2kv(assoc, ary, self)
len = RARRAY_LEN(assoc);
for(i = 0; i < len; i++) {
- pair = RARRAY_CONST_PTR(assoc)[i];
+ pair = RARRAY_AREF(assoc, i);
if (!RB_TYPE_P(pair, T_ARRAY)) {
rb_ary_push(dst, key2keyname(pair));
continue;
}
switch(RARRAY_LEN(assoc)) {
case 2:
- rb_ary_push(dst, RARRAY_CONST_PTR(pair)[2]);
+ rb_ary_push(dst, RARRAY_AREF(pair, 2));
case 1:
- rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
+ rb_ary_push(dst, key2keyname(RARRAY_AREF(pair, 0)));
case 0:
continue;
default:
- rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
+ rb_ary_push(dst, key2keyname(RARRAY_AREF(pair, 0)));
val = rb_ary_new2(RARRAY_LEN(pair) - 1);
rb_ary_cat(val, RARRAY_CONST_PTR(pair) + 1, RARRAY_LEN(pair) - 1);
@@ -654,23 +654,23 @@ assoc2kv_enc(assoc, ary, self)
len = RARRAY_LEN(assoc);
for(i = 0; i < len; i++) {
- pair = RARRAY_CONST_PTR(assoc)[i];
+ pair = RARRAY_AREF(assoc, i);
if (!RB_TYPE_P(pair, T_ARRAY)) {
rb_ary_push(dst, key2keyname(pair));
continue;
}
switch(RARRAY_LEN(assoc)) {
case 2:
- rb_ary_push(dst, get_eval_string_core(RARRAY_CONST_PTR(pair)[2], Qtrue, self));
+ rb_ary_push(dst, get_eval_string_core(RARRAY_AREF(pair, 2), Qtrue, self));
case 1:
- rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
+ rb_ary_push(dst, key2keyname(RARRAY_AREF(pair, 0)));
case 0:
continue;
default:
- rb_ary_push(dst, key2keyname(RARRAY_CONST_PTR(pair)[0]));
+ rb_ary_push(dst, key2keyname(RARRAY_AREF(pair, 0)));
val = rb_ary_new2(RARRAY_LEN(pair) - 1);
rb_ary_cat(val, RARRAY_CONST_PTR(pair) + 1, RARRAY_LEN(pair) - 1);
@@ -694,7 +694,7 @@ push_kv(key, val, args)
{
volatile VALUE ary;
- ary = RARRAY_CONST_PTR(args)[0];
+ ary = RARRAY_AREF(args, 0);
#if 0
rb_ary_push(ary, key2keyname(key));
@@ -704,7 +704,7 @@ push_kv(key, val, args)
if (val == TK_None) return ST_CHECK;
- rb_ary_push(ary, get_eval_string_core(val, Qnil, RARRAY_CONST_PTR(args)[1]));
+ rb_ary_push(ary, get_eval_string_core(val, Qnil, RARRAY_AREF(args, 1)));
return ST_CHECK;
}
@@ -735,20 +735,20 @@ push_kv_enc(key, val, args)
{
volatile VALUE ary;
- ary = RARRAY_CONST_PTR(args)[0];
+ ary = RARRAY_AREF(args, 0);
#if 0
rb_ary_push(ary, key2keyname(key));
if (val != TK_None) {
rb_ary_push(ary, get_eval_string_core(val, Qtrue,
- RARRAY_CONST_PTR(args)[1]));
+ RARRAY_AREF(args, 1)));
}
#endif
rb_ary_push(ary, key2keyname(key));
if (val == TK_None) return ST_CHECK;
- rb_ary_push(ary, get_eval_string_core(val, Qtrue, RARRAY_CONST_PTR(args)[1]));
+ rb_ary_push(ary, get_eval_string_core(val, Qtrue, RARRAY_AREF(args, 1)));
return ST_CHECK;
}
@@ -1494,7 +1494,7 @@ cbsubst_get_subst_key(self, str)
ptr = buf = RSTRING_PTR(ret);
for(i = 0; i < len; i++) {
- VALUE keyval = RARRAY_CONST_PTR(list)[i];
+ VALUE keyval = RARRAY_AREF(list, i);
const char *key = (Check_Type(keyval, T_STRING), StringValueCStr(keyval));
if (*key == '%') {
if (*(key + 2) == '\0') {
@@ -1593,7 +1593,7 @@ cbsubst_table_setup(argc, argv, self)
*/
len = RARRAY_LEN(key_inf);
for(idx = 0; idx < len; idx++) {
- inf = RARRAY_CONST_PTR(key_inf)[idx];
+ inf = RARRAY_AREF(key_inf, idx);
if (!RB_TYPE_P(inf, T_ARRAY)) continue;
infp = RARRAY_CONST_PTR(inf);
@@ -1617,7 +1617,7 @@ cbsubst_table_setup(argc, argv, self)
*/
len = RARRAY_LEN(longkey_inf);
for(idx = 0; idx < len; idx++) {
- inf = RARRAY_CONST_PTR(longkey_inf)[idx];
+ inf = RARRAY_AREF(longkey_inf, idx);
if (!RB_TYPE_P(inf, T_ARRAY)) continue;
infp = RARRAY_CONST_PTR(inf);
@@ -1643,7 +1643,7 @@ cbsubst_table_setup(argc, argv, self)
len = RARRAY_LEN(proc_inf);
for(idx = 0; idx < len; idx++) {
VALUE type, proc;
- inf = RARRAY_CONST_PTR(proc_inf)[idx];
+ inf = RARRAY_AREF(proc_inf, idx);
if (!RB_TYPE_P(inf, T_ARRAY)) continue;
if (RARRAY_LEN(inf) < 2) continue;
type = rb_ary_entry(inf, 0);
@@ -1703,10 +1703,10 @@ cbsubst_scan_args(self, arg_key, val_ary)
}
if (NIL_P(proc)) {
- rb_ary_push(dst, RARRAY_CONST_PTR(val_ary)[idx]);
+ rb_ary_push(dst, RARRAY_AREF(val_ary, idx));
} else {
rb_ary_push(dst, rb_funcall(proc, ID_call, 1,
- RARRAY_CONST_PTR(val_ary)[idx]));
+ RARRAY_AREF(val_ary, idx)));
}
}