[hackers] [sbase] sort: replace loop with MIN() || Jakob Kramer

From: <git_AT_suckless.org>
Date: Sun, 04 May 2014 01:15:30 +0200

commit e535e8d88a12459ddbf3542af6483b242cbd09e0
Author: Jakob Kramer <jakob.kramer_AT_gmx.de>
Date: Sat May 3 18:52:18 2014 +0200

    sort: replace loop with MIN()

diff --git a/sort.c b/sort.c
index deab422..3614853 100644
--- a/sort.c
+++ b/sort.c
_AT_@ -213,17 +213,14 @@ columns(char *line, const struct keydef *kd)
 {
         char *start, *end;
         char *res;
- unsigned int i;
 
         start = skip_columns(line, kd->start_column);
- for(i = 1; i < kd->start_char && *start && !isblank(*start); i++)
- start++;
+ start += MIN(kd->start_char, next_blank(start) - start) - 1;
 
         if(kd->end_column) {
                 end = skip_columns(line, kd->end_column);
                 if(kd->end_char)
- for(i = 1; i < kd->end_char && *end && !isblank(*end); i++)
- end++;
+ end += MIN(kd->end_char, next_blank(end) - end);
                 else
                         end = next_blank(end);
         } else {
Received on Sun May 04 2014 - 01:15:30 CEST

This archive was generated by hypermail 2.3.0 : Sun May 04 2014 - 01:24:10 CEST