diff --git a/ChangeLog b/ChangeLog index 2b9ea2d9b0..0a6fcffa06 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Thu Aug 13 09:01:25 2015 Eric Wong + + * load.c (features_index_add): avoid repeat calculation + Wed Aug 12 21:57:31 2015 Koichi Sasada * id_table.c: IMPL() macro accept op as _opname instead of opname diff --git a/load.c b/load.c index 47c3bfe67c..0a8aedaa4d 100644 --- a/load.c +++ b/load.c @@ -239,16 +239,19 @@ features_index_add(VALUE feature, VALUE offset) 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); } }