Skip to content

Commit efef2c6

Browse files
author
normal
committed
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). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@51559 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
1 parent ccdcaf6 commit efef2c6

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Thu Aug 13 09:01:25 2015 Eric Wong <[email protected]>
2+
3+
* load.c (features_index_add): avoid repeat calculation
4+
15
Wed Aug 12 21:57:31 2015 Koichi Sasada <[email protected]>
26

37
* id_table.c: IMPL() macro accept op as _opname instead of opname

load.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,16 +239,19 @@ features_index_add(VALUE feature, VALUE offset)
239239

240240
p = ext ? ext : feature_end;
241241
while (1) {
242+
long beg;
243+
242244
p--;
243245
while (p >= feature_str && *p != '/')
244246
p--;
245247
if (p < feature_str)
246248
break;
247249
/* Now *p == '/'. We reach this point for every '/' in `feature`. */
248-
short_feature = rb_str_subseq(feature, p + 1 - feature_str, feature_end - p - 1);
250+
beg = p + 1 - feature_str;
251+
short_feature = rb_str_subseq(feature, beg, feature_end - p - 1);
249252
features_index_add_single(short_feature, offset);
250253
if (ext) {
251-
short_feature = rb_str_subseq(feature, p + 1 - feature_str, ext - p - 1);
254+
short_feature = rb_str_subseq(feature, beg, ext - p - 1);
252255
features_index_add_single(short_feature, offset);
253256
}
254257
}

0 commit comments

Comments
 (0)