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

ruby-changes:35952

From: nobu <ko1@a...>
Date: Mon, 20 Oct 2014 01:59:07 +0900 (JST)
Subject: [ruby-changes:35952] nobu:r48033 (trunk): vm_insnhelper.c: refactoring

nobu	2014-10-20 01:58:58 +0900 (Mon, 20 Oct 2014)

  New Revision: 48033

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

  Log:
    vm_insnhelper.c: refactoring
    
    * vm_insnhelper.c (vm_getivar): move common expressions.

  Modified files:
    trunk/vm_insnhelper.c
Index: vm_insnhelper.c
===================================================================
--- vm_insnhelper.c	(revision 48032)
+++ vm_insnhelper.c	(revision 48033)
@@ -495,12 +495,11 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_c https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L495
     if (RB_TYPE_P(obj, T_OBJECT)) {
 	VALUE val = Qundef;
 	VALUE klass = RBASIC(obj)->klass;
+	const long len = ROBJECT_NUMIV(obj);
+	const VALUE *const ptr = ROBJECT_IVPTR(obj);
 
-	if (LIKELY((!is_attr && ic->ic_serial == RCLASS_SERIAL(klass)) ||
-		   (is_attr && ci->aux.index > 0))) {
+	if (LIKELY(is_attr ? ci->aux.index > 0 : ic->ic_serial == RCLASS_SERIAL(klass))) {
 	    int index = !is_attr ? (int)ic->ic_value.index : ci->aux.index - 1;
-	    long len = ROBJECT_NUMIV(obj);
-	    VALUE *ptr = ROBJECT_IVPTR(obj);
 
 	    if (index < len) {
 		val = ptr[index];
@@ -508,8 +507,6 @@ vm_getivar(VALUE obj, ID id, IC ic, rb_c https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L507
 	}
 	else {
 	    st_data_t index;
-	    long len = ROBJECT_NUMIV(obj);
-	    VALUE *ptr = ROBJECT_IVPTR(obj);
 	    struct st_table *iv_index_tbl = ROBJECT_IV_INDEX_TBL(obj);
 
 	    if (iv_index_tbl) {

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

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