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

T Sureshkumar tsureshkumar at novell.com
Mon Sep 19 11:21:28 EDT 2005


>>> On Mon, Sep 19, 2005 at  8:23 pm, in message
<DA63C6E8B207E748B20D46DFED7B772D01A859CF at dhost002-45.dex002.intermedia.net>,
"Boris Kirzner" <borisk at mainsoft.com> wrote: 
>> >>@@ - 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.

that is exactly the point I am hitting. 


status after the "if" conditions (assuming all other factors are
equal):

                              your logic           correct logic
   _filter   - filter 
1.  null    - null           true                     true
2.  null    - x              *true*                  false
3.  x       - null           false                    false
4.  x       - x              true                     true
5.  x       - y              false                    false


see the second case.

suresh.

> 
> 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