[OPTIM] halog: minor speedup by using unlikely()
By moving the filter-specific code out of the loop, we can slightly
speed it up (3%).
diff --git a/contrib/halog/halog.c b/contrib/halog/halog.c
index 8f24030..81ffa82 100644
--- a/contrib/halog/halog.c
+++ b/contrib/halog/halog.c
@@ -440,7 +440,7 @@
linenum++;
test = 1;
- if (filter & FILT_TIME_RESP) {
+ if (unlikely(filter & FILT_TIME_RESP)) {
int tps;
/* only report lines with response times larger than filter_time_resp */
@@ -473,7 +473,7 @@
test &= (tps >= filter_time_resp) ^ !!(filter & FILT_INVERT_TIME_RESP);
}
- if (filter & FILT_ERRORS_ONLY) {
+ if (unlikely(filter & FILT_ERRORS_ONLY)) {
/* only report erroneous status codes */
b = field_start(line, STATUS_FIELD + skip_fields);
if (!*b) {
@@ -492,7 +492,7 @@
if (!test)
continue;
- if (filter & (FILT_ACC_COUNT|FILT_ACC_DELAY)) {
+ if (unlikely(filter & (FILT_ACC_COUNT|FILT_ACC_DELAY))) {
b = field_start(line, ACCEPT_FIELD + skip_fields);
if (!*b) {
truncated_line(linenum, line);
@@ -512,7 +512,7 @@
continue;
}
- if (filter & (FILT_GRAPH_TIMERS|FILT_PERCENTILE)) {
+ if (unlikely(filter & (FILT_GRAPH_TIMERS|FILT_PERCENTILE))) {
int f;
b = field_start(line, TIME_FIELD + skip_fields);
@@ -593,7 +593,7 @@
continue;
}
- if (filter & FILT_COUNT_STATUS) {
+ if (unlikely(filter & FILT_COUNT_STATUS)) {
b = field_start(line, STATUS_FIELD + skip_fields);
if (!*b) {
truncated_line(linenum, line);
@@ -608,7 +608,7 @@
/* all other cases mean we just want to count lines */
tot++;
- if (!(filter & FILT_COUNT_ONLY))
+ if (unlikely(!(filter & FILT_COUNT_ONLY)))
puts(line);
}