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

ruby-changes:39478

From: normal <ko1@a...>
Date: Thu, 13 Aug 2015 09:02:06 +0900 (JST)
Subject: [ruby-changes:39478] normal:r51559 (trunk): load.c (features_index_add): avoid repeat calculation

normal	2015-08-13 09:02:01 +0900 (Thu, 13 Aug 2015)

  New Revision: 51559

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

  Log:
    load.c (features_index_add): avoid repeat calculation
    
    Reduce cognitive overhead, eye strain and keep lines less than 80
    columns to benefit users of giant fonts (honestly I prefer 64 column
    wrap :P).

  Modified files:
    trunk/ChangeLog
    trunk/load.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 51558)
+++ ChangeLog	(revision 51559)
@@ -1,3 +1,7 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Thu Aug 13 09:01:25 2015  Eric Wong  <e@8...>
+
+	* load.c (features_index_add): avoid repeat calculation
+
 Wed Aug 12 21:57:31 2015  Koichi Sasada  <ko1@a...>
 
 	* id_table.c: IMPL() macro accept op as _opname instead of opname
Index: load.c
===================================================================
--- load.c	(revision 51558)
+++ load.c	(revision 51559)
@@ -239,16 +239,19 @@ features_index_add(VALUE feature, VALUE https://github.com/ruby/ruby/blob/trunk/load.c#L239
 
     p = ext ? ext : feature_end;
     while (1) {
+	long beg;
+
 	p--;
 	while (p >= feature_str && *p != '/')
 	    p--;
 	if (p < feature_str)
 	    break;
 	/* Now *p == '/'.  We reach this point for every '/' in `feature`. */
-	short_feature = rb_str_subseq(feature, p + 1 - feature_str, feature_end - p - 1);
+	beg = p + 1 - feature_str;
+	short_feature = rb_str_subseq(feature, beg, feature_end - p - 1);
 	features_index_add_single(short_feature, offset);
 	if (ext) {
-	    short_feature = rb_str_subseq(feature, p + 1 - feature_str, ext - p - 1);
+	    short_feature = rb_str_subseq(feature, beg, ext - p - 1);
 	    features_index_add_single(short_feature, offset);
 	}
     }

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

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