From: Frédéric Marchal Date: Sun, 26 Aug 2012 15:16:31 +0000 (+0200) Subject: Change the structure to search for the current log format X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=29a9fe97f03f57c06d0403c08546808c0e9f8566;p=thirdparty%2Fsarg.git Change the structure to search for the current log format Rewrite the loop to scan through the known log formats to make it more readable and let the compiler optimize it. --- diff --git a/readlog.c b/readlog.c index 39f9c70..8558f5d 100644 --- a/readlog.c +++ b/readlog.c @@ -261,17 +261,13 @@ int ReadLogFile(struct ReadLogDataStruct *Filter) // find out what line format to use if (log_entry_status==RLRC_Unknown) { - x=0; - while (x<(int)(sizeof(LogFormats)/sizeof(*LogFormats))) { - if (LogFormats[x]!=current_format) - { - memset(&log_entry,0,sizeof(log_entry)); - log_entry_status=LogFormats[x]->ReadEntry(linebuf,&log_entry); - if (log_entry_status!=RLRC_Unknown) break; - } - x++; + for (x=0 ; x<(int)(sizeof(LogFormats)/sizeof(*LogFormats)) ; x++) { + if (LogFormats[x]==current_format) continue; + memset(&log_entry,0,sizeof(log_entry)); + log_entry_status=LogFormats[x]->ReadEntry(linebuf,&log_entry); + if (log_entry_status!=RLRC_Unknown) break; } - if (x<0 || x>=(int)(sizeof(LogFormats)/sizeof(*LogFormats))) { + if (x>=(int)(sizeof(LogFormats)/sizeof(*LogFormats))) { debuga(_("Unknown line format found in input log file %s:\n%s\n"),arq,linebuf); exit(EXIT_FAILURE); }