Free cookie consent management tool by TermsFeed Policy Generator

Changes between Initial Version and Version 1 of Ticket #1522, comment 9


Ignore:
Timestamp:
05/13/11 11:08:26 (13 years ago)
Author:
cneumuel
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #1522, comment 9

    initial v1  
    11 * The reason `IsArray` returns less objects than checking for `IEnumerable` is that it's quite different if an `Enumerator` of an `IEnumerable` is used rather than going deeper down into the object until an array is reached. An example is the `Dictionary`. `dict is IEnumerable` returns true, resulting in enumerating that dictionary. The implementation of the enumerator reveals that `KeyValuePair<TKey, TValue>` objects are created within the enumerator. If `IsArray` is used, `dict.IsArray` returns false, resulting in a further recursion into the dictionary object. In there an array of `Entry<TKey, TValue>[]` is found, which is then used. So in this example all the `KeyValuePair` objects are missing when `IsArray` is used (which is good!).
    2  * I have not noticed a big performance difference between `IsArray` and `is IEnumerable`, so in my opinion `IsArray` would be the way to go.
     2 * ~~I have not noticed a big performance difference between `IsArray` and `is IEnumerable`, so in my opinion `IsArray` would be the way to go.~~ I could reproduce the performance difference, but I could mostly fix it by handling dictionaries in a special way.