@@ -106,15 +106,34 @@ ICanBeEvaluated archRuleCreator
106106 var filteredObjectsList = filteredObjects . ToList ( ) ;
107107 if ( filteredObjectsList . IsNullOrEmpty ( ) && ! CheckEmpty ( ) )
108108 {
109- yield return new EvaluationResult (
110- null ,
111- new StringIdentifier ( "" ) ,
112- false ,
113- "There are no objects matching the criteria" ,
114- archRuleCreator ,
115- architecture
109+ return new [ ]
110+ {
111+ new EvaluationResult (
112+ null ,
113+ new StringIdentifier ( "" ) ,
114+ false ,
115+ "There are no objects matching the criteria" ,
116+ archRuleCreator ,
117+ architecture
118+ ) ,
119+ } ;
120+ }
121+
122+ if ( _conditionElements . All ( e => e . IsOrdered ( ) ) )
123+ {
124+ var conditionResults = _conditionElements
125+ . Select ( conditionElement =>
126+ conditionElement . Check ( filteredObjectsList , architecture ) . ToList ( )
127+ )
128+ . ToList ( ) ;
129+ return filteredObjectsList . Select (
130+ ( t , i ) =>
131+ CreateEvaluationResult (
132+ conditionResults . Select ( results => results [ i ] ) ,
133+ architecture ,
134+ archRuleCreator
135+ )
116136 ) ;
117- yield break ;
118137 }
119138
120139 //rough heuristic - if we have small number of comparisons, we are fine with sequential search
@@ -129,14 +148,13 @@ ICanBeEvaluated archRuleCreator
129148 )
130149 . ToList ( ) ;
131150
132- foreach ( var t in filteredObjectsList )
133- {
134- yield return CreateEvaluationResult (
151+ return filteredObjectsList . Select ( t =>
152+ CreateEvaluationResult (
135153 FindResultsForObject ( conditionResults , t ) ,
136154 architecture ,
137155 archRuleCreator
138- ) ;
139- }
156+ )
157+ ) ;
140158 }
141159 else
142160 {
@@ -145,15 +163,13 @@ ICanBeEvaluated archRuleCreator
145163 conditionElement . Check ( filteredObjectsList , architecture ) . ToList ( )
146164 )
147165 . ToList ( ) ;
148-
149- foreach ( var t in filteredObjectsList )
150- {
151- yield return CreateEvaluationResult (
166+ return filteredObjectsList . Select ( t =>
167+ CreateEvaluationResult (
152168 FindResultsForObject ( conditionResults , t ) ,
153169 architecture ,
154170 archRuleCreator
155- ) ;
156- }
171+ )
172+ ) ;
157173 }
158174 }
159175
@@ -349,6 +365,11 @@ Architecture architecture
349365 . Select ( result => new ConditionElementResult ( result , _logicalConjunction ) ) ;
350366 }
351367
368+ public bool IsOrdered ( )
369+ {
370+ return _condition is IOrderedCondition < T > ;
371+ }
372+
352373 public bool CheckEmpty ( bool currentResult )
353374 {
354375 if ( _condition == null )
0 commit comments