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

ruby-changes:27593

From: nobu <ko1@a...>
Date: Sat, 9 Mar 2013 08:54:50 +0900 (JST)
Subject: [ruby-changes:27593] nobu:r39645 (trunk): load.c: move loop invariant condition

nobu	2013-03-09 08:54:41 +0900 (Sat, 09 Mar 2013)

  New Revision: 39645

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

  Log:
    load.c: move loop invariant condition
    
    * load.c (rb_feature_p): move this_feature_index condition which is
      loop invariant.

  Modified files:
    trunk/load.c

Index: load.c
===================================================================
--- load.c	(revision 39644)
+++ load.c	(revision 39645)
@@ -406,40 +406,42 @@ rb_feature_p(const char *feature, const https://github.com/ruby/ruby/blob/trunk/load.c#L406
        or ends in '/'.  This includes both match forms above, as well
        as any distractors, so we may ignore all other entries in `features`.
      */
-    for (i = 0; !NIL_P(this_feature_index); i++) {
-	VALUE entry;
-	long index;
-	if (RB_TYPE_P(this_feature_index, T_ARRAY)) {
-	    if (i >= RARRAY_LEN(this_feature_index)) break;
-	    entry = RARRAY_PTR(this_feature_index)[i];
-	}
-	else {
-	    if (i > 0) break;
-	    entry = this_feature_index;
-	}
-	index = FIX2LONG(entry);
+    if (!NIL_P(this_feature_index)) {
+	for (i = 0; ; i++) {
+	    VALUE entry;
+	    long index;
+	    if (RB_TYPE_P(this_feature_index, T_ARRAY)) {
+		if (i >= RARRAY_LEN(this_feature_index)) break;
+		entry = RARRAY_PTR(this_feature_index)[i];
+	    }
+	    else {
+		if (i > 0) break;
+		entry = this_feature_index;
+	    }
+	    index = FIX2LONG(entry);
 
-	v = RARRAY_PTR(features)[index];
-	f = StringValuePtr(v);
-	if ((n = RSTRING_LEN(v)) < len) continue;
-	if (strncmp(f, feature, len) != 0) {
-	    if (expanded) continue;
-	    if (!load_path) load_path = rb_get_expanded_load_path();
-	    if (!(p = loaded_feature_path(f, n, feature, len, type, load_path)))
-		continue;
-	    expanded = 1;
-	    f += RSTRING_LEN(p) + 1;
-	}
-	if (!*(e = f + len)) {
-	    if (ext) continue;
-	    return 'u';
-	}
-	if (*e != '.') continue;
-	if ((!rb || !ext) && (IS_SOEXT(e) || IS_DLEXT(e))) {
-	    return 's';
-	}
-	if ((rb || !ext) && (IS_RBEXT(e))) {
-	    return 'r';
+	    v = RARRAY_PTR(features)[index];
+	    f = StringValuePtr(v);
+	    if ((n = RSTRING_LEN(v)) < len) continue;
+	    if (strncmp(f, feature, len) != 0) {
+		if (expanded) continue;
+		if (!load_path) load_path = rb_get_expanded_load_path();
+		if (!(p = loaded_feature_path(f, n, feature, len, type, load_path)))
+		    continue;
+		expanded = 1;
+		f += RSTRING_LEN(p) + 1;
+	    }
+	    if (!*(e = f + len)) {
+		if (ext) continue;
+		return 'u';
+	    }
+	    if (*e != '.') continue;
+	    if ((!rb || !ext) && (IS_SOEXT(e) || IS_DLEXT(e))) {
+		return 's';
+	    }
+	    if ((rb || !ext) && (IS_RBEXT(e))) {
+		return 'r';
+	    }
 	}
     }
 

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

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