[前][次][番号順一覧][スレッド一覧]

ruby-changes:36114

From: nobu <ko1@a...>
Date: Thu, 30 Oct 2014 15:33:23 +0900 (JST)
Subject: [ruby-changes:36114] nobu:r48195 (trunk): tkutil.c: remove useless branches

nobu	2014-10-30 15:33:11 +0900 (Thu, 30 Oct 2014)

  New Revision: 48195

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48195

  Log:
    tkutil.c: remove useless branches
    
    * ext/tk/tkutil/tkutil.c (cbsubst_table_setup): remove useless
      branches and get rid of out of bound access.

  Modified files:
    trunk/ext/tk/tkutil/tkutil.c
Index: ext/tk/tkutil/tkutil.c
===================================================================
--- ext/tk/tkutil/tkutil.c	(revision 48194)
+++ ext/tk/tkutil/tkutil.c	(revision 48195)
@@ -1562,16 +1562,8 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1562
     inf = RARRAY_PTR(key_inf)[idx];
     if (!RB_TYPE_P(inf, T_ARRAY)) continue;
 
-    if (RB_TYPE_P(RARRAY_PTR(inf)[0], T_STRING)) {
-      chr = *(RSTRING_PTR(RARRAY_PTR(inf)[0]));
-    } else {
-      chr = NUM2CHR(RARRAY_PTR(inf)[0]);
-    }
-    if (RB_TYPE_P(RARRAY_PTR(inf)[1], T_STRING)) {
-      subst_inf->type[chr] = *(RSTRING_PTR(RARRAY_PTR(inf)[1]));
-    } else {
-      subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]);
-    }
+    chr = NUM2CHR(RARRAY_PTR(inf)[0]);
+    subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]);
 
     subst_inf->full_subst_length += 3;
 
@@ -1606,11 +1598,7 @@ cbsubst_table_setup(argc, argv, self) https://github.com/ruby/ruby/blob/trunk/ext/tk/tkutil/tkutil.c#L1598
       subst_inf->key[chr][RSTRING_LEN(RARRAY_PTR(inf)[0])] = '\0';
     }
 #endif
-    if (RB_TYPE_P(RARRAY_PTR(inf)[1], T_STRING)) {
-      subst_inf->type[chr] = *(RSTRING_PTR(RARRAY_PTR(inf)[1]));
-    } else {
-      subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]);
-    }
+    subst_inf->type[chr] = NUM2CHR(RARRAY_PTR(inf)[1]);
 
     subst_inf->full_subst_length += (subst_inf->keylen[chr] + 2);
 

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]