@@ -171,35 +171,40 @@ processBatchMultiRuleset(batch_t *pBatch)
171171 int i ;
172172 int iStart ; /* start index of partial batch */
173173 int iNew ; /* index for new (temporary) batch */
174+ int bHaveUnprocessed ; /* do we (still) have unprocessed entries? (loop term predicate) */
174175 DEFiRet ;
175176
176- CHKiRet (batchInit (& snglRuleBatch , pBatch -> nElem ));
177- snglRuleBatch .pbShutdownImmediate = pBatch -> pbShutdownImmediate ;
178-
179- while (1 ) { /* loop broken inside */
177+ do {
178+ bHaveUnprocessed = 0 ;
180179 /* search for first unprocessed element */
181180 for (iStart = 0 ; iStart < pBatch -> nElem && pBatch -> pElem [iStart ].state == BATCH_STATE_DISC ; ++ iStart )
182181 /* just search, no action */ ;
183-
184182 if (iStart == pBatch -> nElem )
185- FINALIZE ; /* everything processed */
183+ break ; /* everything processed */
186184
187185 /* prepare temporary batch */
186+ CHKiRet (batchInit (& snglRuleBatch , pBatch -> nElem ));
187+ snglRuleBatch .pbShutdownImmediate = pBatch -> pbShutdownImmediate ;
188188 currRuleset = batchElemGetRuleset (pBatch , iStart );
189189 iNew = 0 ;
190190 for (i = iStart ; i < pBatch -> nElem ; ++ i ) {
191191 if (batchElemGetRuleset (pBatch , i ) == currRuleset ) {
192- batchCopyElem (& (snglRuleBatch .pElem [iNew ++ ]), & (pBatch -> pElem [i ]));
192+ /* for performance reasons, we copy only those members that we actually need */
193+ snglRuleBatch .pElem [iNew ].pUsrp = pBatch -> pElem [i ].pUsrp ;
194+ snglRuleBatch .pElem [iNew ].state = pBatch -> pElem [i ].state ;
195+ ++ iNew ;
193196 /* We indicate the element also as done, so it will not be processed again */
194197 pBatch -> pElem [i ].state = BATCH_STATE_DISC ;
198+ } else {
199+ bHaveUnprocessed = 1 ;
195200 }
196201 }
197202 snglRuleBatch .nElem = iNew ; /* was left just right by the for loop */
198203 batchSetSingleRuleset (& snglRuleBatch , 1 );
199204 /* process temp batch */
200205 processBatch (& snglRuleBatch );
201- }
202- batchFree ( & snglRuleBatch );
206+ batchFree ( & snglRuleBatch );
207+ } while ( bHaveUnprocessed == 1 );
203208
204209finalize_it :
205210 RETiRet ;
0 commit comments