> I don't think I totally understand what you want to do. Can you explain in a
> little more detail? I'm slightly cautious about changing anything in the
> core, because although the changes are probably straightforward, there could
> be a substantial impact on tests to be written. Also, the compositional
> nature of the content pipeline means that - depending on exactly what you
> want - doing things like exposing the CompareModifiedTimes delegate might be
> problematic. But I could see the filter delegate on AllTopics being
> reasonable to implement.
>
OK, so I'll start at the beginning and try to paint somewhat of a
coherent picture of what I've been thinking.
First, my problem was that I was calling
AllTopicsSortedLastModifiedDescending. This in turn calls the public
method AllTopics(IncludePolicy,SortDelegate) with
CompareModificationTime as the SortDelegate. I was then culling out
the things that I didn't want in the returned collection. Before your
latest work, this was killing my performance because, even though I
was only interested in 5% of the results, it was doing the sort work
of the whole thing.
So here was my calling code:
QualifiedTopicNameCollection qc;
qc = namespace.AllTopicsSortedLastModifiedDescending(); // slow!
foreach (QTN in qc)
{
//remove things I don't like based on simple tests (so it's reasonbly fast)
}
My first thought was that I'd call AllTopics() (with no sorting), then
I'd cull out what I didn't want, and then I'd just call
QualifiedTopicNameCollection.Sort() to get them sorted the way I
wanted to. This is good because now I'm only sorting the things that
I'm interested in, but it is bad because the sorting algorithm that is
used by AllTopicsSortedByDescending() is private. I could try to
reimplement it myself (I have the source you know ;)) but that seemed
silly. Why would we force people that wanted to do the most typical
sort to re-implement it by hand? This made no sense to me, so the
first thing I did was to make CompareModificationTime public. So now
my code looked like this:
QTNC qc = namespace.AllTopics(); // fast
qc.RemoveAll(FilterDelegate); // still reasonably fast
qc.Sort(NamespaceManager.CompareModificationTime); // fast since there
are few elements
My thought for exposing the CompareModificationTime method as public
is simply this: we already have a public method allowing us to specify
which sorting algorithm we want to apply, we have a reasonable default
behavior, why would we not expose it?
So after pondering this a bit, it seemed even more reasonable to just
supply AllTopics with the FilterDelegate (or SelectionDelegate
depending on if we wanted to specify what to remove or what to keep)
and then this behavior is all kept in one place. So now my code looks
like this
QTNC qc = namespace.AllTopics(ImportPolicy, SortDelegate, FilterDelegate);
Strictly speaking, we are adding nothing to the core. I could very
easily write a SortDelegate that did exactly what
CompareModificationTime does if it is not exposed. I can do the code
my second example myself. It just seems quite reasonable that I'd be
able to do the third bit as well.
Let me know if I've not cleared up the waters enough.
-nathan
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Flexwiki-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/flexwiki-users