From 6982d4908112f14c20ae0a3de7a954c574b76172 Mon Sep 17 00:00:00 2001 From: "hwaara%chello.se" Date: Thu, 6 Sep 2001 19:30:13 +0000 Subject: [PATCH] #72203, optimize local search a bit by short-circuiting our evaluation code. Original patch submitted by Michael Tiemann. r=naving, sr=sspitzer. --- mailnews/base/search/src/nsMsgLocalSearch.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/mailnews/base/search/src/nsMsgLocalSearch.cpp b/mailnews/base/search/src/nsMsgLocalSearch.cpp index 24365cb0c2b..3d0b4380af4 100644 --- a/mailnews/base/search/src/nsMsgLocalSearch.cpp +++ b/mailnews/base/search/src/nsMsgLocalSearch.cpp @@ -153,23 +153,23 @@ PRBool nsMsgSearchBoolExpression::OfflineEvaluate() // otherwise we must recursively determine the value of our sub expressions PRBool result1 = PR_TRUE; // always default to false positives PRBool result2 = PR_TRUE; - + if (m_leftChild) + { result1 = m_leftChild->OfflineEvaluate(); + if (m_boolOp == nsMsgSearchBooleanOp::BooleanOR && result1 || + (m_boolOp == nsMsgSearchBooleanOp::BooleanAND && !result1)) + return result1; + } + if (m_rightChild) result2 = m_rightChild->OfflineEvaluate(); if (m_boolOp == nsMsgSearchBooleanOp::BooleanOR) - { - if (result1 || result2) - return PR_TRUE; - } - - if (m_boolOp == nsMsgSearchBooleanOp::BooleanAND) - { - if (result1 && result2) - return PR_TRUE; - } + return (result1 || result2) ? PR_TRUE : PR_FALSE; + + if (m_boolOp == nsMsgSearchBooleanOp::BooleanAND && result1 && result2) + return PR_TRUE; return PR_FALSE; }