* [PATCH] load.c (features_index_add): avoid repeat calculation
@ 2015-08-12 23:51 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2015-08-12 23:51 UTC (permalink / raw)
To: spew
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).
---
load.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/load.c b/load.c
index 47c3bfe..0a8aeda 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);
}
}
--
EW
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-08-12 23:51 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-12 23:51 [PATCH] load.c (features_index_add): avoid repeat calculation Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).