]> mj.ucw.cz Git - libucw.git/commitdiff
Logging: A minor optimization of log_apply_limits().
authorMartin Mares <mj@ucw.cz>
Sat, 21 Feb 2009 21:08:40 +0000 (22:08 +0100)
committerMartin Mares <mj@ucw.cz>
Sat, 21 Feb 2009 21:08:40 +0000 (22:08 +0100)
Exit early if all types in the set are unknown.

ucw/log-conf.c

index 8989595d9885fd260e93a8a9dddde4cff85f557f..15be98e8d0df313232bf79cfea80f533d00f949d 100644 (file)
@@ -244,6 +244,10 @@ log_limiter(struct log_stream *ls, struct log_msg *m)
 static void
 log_apply_limits(struct log_stream *ls, struct limit_config *lim)
 {
+  uns mask = log_type_mask(&lim->types);
+  if (!mask)
+    return;
+
   if (!ls->user_data)
     {
       ls->user_data = cf_malloc_zero(LS_NUM_TYPES * sizeof(struct token_bucket_filter *));
@@ -255,7 +259,6 @@ log_apply_limits(struct log_stream *ls, struct limit_config *lim)
   tbf->burst = lim->burst;
   tbf_init(tbf);
 
-  uns mask = log_type_mask(&lim->types);
   for (uns i=0; i < LS_NUM_TYPES; i++)
     if (mask & (1 << i))
       limits[i] = tbf;