diff options
author | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2011-01-06 07:11:29 +0000 |
---|---|---|
committer | hiro <hiro@ee746299-78ed-0310-b773-934348b2243d> | 2011-01-06 07:11:29 +0000 |
commit | fe0155ed95241fa89d9065785ccc4fe1adc60a61 (patch) | |
tree | da8986d46ee67debd8b9e63121cf087fa22f2c54 /libsylph | |
parent | 03dcfc2edfaf453553b26275e991e6f9c14b9422 (diff) |
optimized filter rule matching by modifying the order of condition matching.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@2779 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'libsylph')
-rw-r--r-- | libsylph/filter.c | 62 |
1 files changed, 54 insertions, 8 deletions
diff --git a/libsylph/filter.c b/libsylph/filter.c index 288564a9..1a4c1c29 100644 --- a/libsylph/filter.c +++ b/libsylph/filter.c @@ -368,20 +368,66 @@ gboolean filter_match_rule(FilterRule *rule, MsgInfo *msginfo, GSList *hlist, if (rule->bool_op == FLT_AND) { for (cur = rule->cond_list; cur != NULL; cur = cur->next) { cond = (FilterCond *)cur->data; - matched = filter_match_cond(cond, msginfo, hlist, - fltinfo); - if (matched == FALSE) - return FALSE; + if (cond->type >= FLT_COND_SIZE_GREATER) { + matched = filter_match_cond + (cond, msginfo, hlist, fltinfo); + if (matched == FALSE) + return FALSE; + } + } + + for (cur = rule->cond_list; cur != NULL; cur = cur->next) { + cond = (FilterCond *)cur->data; + if (cond->type <= FLT_COND_TO_OR_CC) { + matched = filter_match_cond + (cond, msginfo, hlist, fltinfo); + if (matched == FALSE) + return FALSE; + } + } + + for (cur = rule->cond_list; cur != NULL; cur = cur->next) { + cond = (FilterCond *)cur->data; + if (cond->type == FLT_COND_BODY || + cond->type == FLT_COND_CMD_TEST) { + matched = filter_match_cond + (cond, msginfo, hlist, fltinfo); + if (matched == FALSE) + return FALSE; + } } return TRUE; } else if (rule->bool_op == FLT_OR) { for (cur = rule->cond_list; cur != NULL; cur = cur->next) { cond = (FilterCond *)cur->data; - matched = filter_match_cond(cond, msginfo, hlist, - fltinfo); - if (matched == TRUE) - return TRUE; + if (cond->type >= FLT_COND_SIZE_GREATER) { + matched = filter_match_cond + (cond, msginfo, hlist, fltinfo); + if (matched == TRUE) + return TRUE; + } + } + + for (cur = rule->cond_list; cur != NULL; cur = cur->next) { + cond = (FilterCond *)cur->data; + if (cond->type <= FLT_COND_TO_OR_CC) { + matched = filter_match_cond + (cond, msginfo, hlist, fltinfo); + if (matched == TRUE) + return TRUE; + } + } + + for (cur = rule->cond_list; cur != NULL; cur = cur->next) { + cond = (FilterCond *)cur->data; + if (cond->type == FLT_COND_BODY || + cond->type == FLT_COND_CMD_TEST) { + matched = filter_match_cond + (cond, msginfo, hlist, fltinfo); + if (matched == TRUE) + return TRUE; + } } return FALSE; |