]> git.ipfire.org Git - thirdparty/sarg.git/commitdiff
Change the structure to search for the current log format
authorFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 26 Aug 2012 15:16:31 +0000 (17:16 +0200)
committerFrédéric Marchal <fmarchal@users.sourceforge.net>
Sun, 26 Aug 2012 15:16:31 +0000 (17:16 +0200)
Rewrite the loop to scan through the known log formats to make it more
readable and let the compiler optimize it.

readlog.c

index 39f9c708395af0405ef7bc6302c1f98fb469eb3d..8558f5d53f595bd52357cd507b40e400735b3cca 100644 (file)
--- 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);
                                }