Tiny optimisation in the filter primop
This commit is contained in:
		
							parent
							
								
									094a08f839
								
							
						
					
					
						commit
						3100b29fc5
					
				
					 1 changed files with 9 additions and 2 deletions
				
			
		|  | @ -950,15 +950,22 @@ static void prim_filter(EvalState & state, Value * * args, Value & v) | ||||||
|     Value * vs[args[1]->list.length]; |     Value * vs[args[1]->list.length]; | ||||||
|     unsigned int k = 0; |     unsigned int k = 0; | ||||||
| 
 | 
 | ||||||
|  |     bool same = true; | ||||||
|     for (unsigned int n = 0; n < args[1]->list.length; ++n) { |     for (unsigned int n = 0; n < args[1]->list.length; ++n) { | ||||||
|         Value res; |         Value res; | ||||||
|         state.callFunction(*args[0], *args[1]->list.elems[n], res); |         state.callFunction(*args[0], *args[1]->list.elems[n], res); | ||||||
|         if (state.forceBool(res)) |         if (state.forceBool(res)) | ||||||
|             vs[k++] = args[1]->list.elems[n]; |             vs[k++] = args[1]->list.elems[n]; | ||||||
|  |         else | ||||||
|  |             same = false; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     state.mkList(v, k); |     if (same) | ||||||
|     for (unsigned int n = 0; n < k; ++n) v.list.elems[n] = vs[n]; |         v = *args[1]; | ||||||
|  |     else { | ||||||
|  |         state.mkList(v, k); | ||||||
|  |         for (unsigned int n = 0; n < k; ++n) v.list.elems[n] = vs[n]; | ||||||
|  |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue