[Mono-dev] RE: [Mono-devel-list] System.Data : DataTable.Select performance

Boris Kirzner borisk at mainsoft.com
Mon Sep 19 10:53:58 EDT 2005


> >>@@ -193,9 +206,14 @@
> >>  				return false;
> >>  			}
> >>-			if (_filter != filter)
> >>-				return false;
> >>+			if (_filter != null) {
> >>+				if (!_filter.Equals (filter))
> >>+					return false;
> >>+			}
> >>+			else if (filter != null)
> >>+					return false;
> 
> First thing is that this whole code above can be simplified into
> 
> if (_filter != null && !_filter.Equals (filter))
> 	return false;
> 
> and also, this logic is wrong. if you are looking for a 
> non-null filter, an index with null filter would also match up.

No, the null-filter index is supposed to hold more records (rows) that a
non-null filter one, so getting non-null filter index in the case I'm
looking for a null-filter one will lead to missing rows in search and,
in opposite case (null filter instead of non-null one) - to the spare
rows in search.
So the exact logic is that two keys are the same only if their filters
are the same (or both null). In any other case (only one of the filters
is null or filters are not equal), the keys differ.

Boris.

> 
> So, IMO, it should be
> 
> if ( (_filter != null && !_filter.Equals (filter)) /* equals compare 
> */ 		|| (_filter != filter)) /* null compare */
> 	return false;
> 
This is ok, but it is exactly the same logic as in the original patch.

--
Boris Kirzner
Mono R&D team, Mainsoft Corporation.
Blogging at http://boriskirzner.blogspot.com/  



More information about the Mono-devel-list mailing list