From: Frédéric Marchal Date: Fri, 8 Jan 2010 15:32:48 +0000 (+0000) Subject: A few trivial optimizations X-Git-Tag: v2_2_7~24 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=65740c50a98a50e11a0670bc609b2d32fe848c98;p=thirdparty%2Fsarg.git A few trivial optimizations --- diff --git a/grepday.c b/grepday.c index 6eca22d..d5d8bde 100644 --- a/grepday.c +++ b/grepday.c @@ -245,9 +245,10 @@ void greport_day(const char *user) char csort[255]; char data[20]; int count=0; - char oday[20]; - char day[20]; - char bytes[20]; + int oday=0; + int day=0; + long long int llday; + long long int bytes; char ftime[128]; long long int tot=0; time_t t; @@ -443,37 +444,37 @@ void greport_day(const char *user) exit(1); } getword_start(&gwarea1,data); - if (getword(day,sizeof(day),&gwarea1,'/')<0) { + if (getword_atoll(&llday,&gwarea1,'/')<0) { printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp5); exit(1); } if(strcmp(DateFormat,"u") == 0) { - if (getword(day,sizeof(day),&gwarea1,'/')<0) { + if (getword_atoll(&llday,&gwarea1,'/')<0) { printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp5); exit(1); } } + day=(int)llday; if(!count) { - strcpy(oday,day); + oday=day; count++; } - if (getword(bytes,sizeof(bytes),&gwarea,'\t')<0 || getword(bytes,sizeof(bytes),&gwarea,'\t')<0) { + if (getword_skip(20,&gwarea,'\t')<0 || getword_atoll(&bytes,&gwarea,'\t')<0) { printf("SARG: Maybe you have a broken record or garbage in your %s file.\n",tmp5); exit(1); } - if(strcmp(oday,day) != 0) { - strcpy(warea,oday); - x1 = 44 +(atoi(oday) * 20); + if(oday!=day) { + x1 = 44 +(oday * 20); bar(x1,tot); - strcpy(oday,day); + oday=day; tot=0; } - tot=tot+my_atoll(bytes); + tot+=bytes; } if(tot) { - x1 = 44 +(atoi(day) * 20); + x1 = 44 +(day * 20); bar(x1,tot); } diff --git a/report.c b/report.c index 6547c6d..05998e7 100644 --- a/report.c +++ b/report.c @@ -328,7 +328,7 @@ void gerarel(void) if(email[0] == '\0') { if(strstr(ReportType,"downloads") != 0) download_report(); - if(strlen(DansGuardianConf) > 0) { + if(DansGuardianConf[0] != '\0') { strcpy(wdirname,dirname); dansguardian_log(); } @@ -349,7 +349,7 @@ void gerarel(void) if(smartfilter) smartfilter_report(); - if(strlen(DansGuardianConf) > 0) dansguardian_report(); + if(DansGuardianConf[0] != '\0') dansguardian_report(); squidguard_report();