Steps to replicate the issue (include links if applicable):
This is the same scenario as in T428372.
- Create a large article list (e.g. ~20,000 articles in category Year of birth missing)
- Remove a single item
- Start processing with a pre-parse setting and continued skips.
Another scenario:
- Paste a list of 37 Rules into the ReplaceSpecial dialog.
What happens?:
Visibly slow processing of remove an item. Visibly slow processing of redraw in the article list, especially when scrolling. Visibly slow processing, with flashing of the details box, in the ReplaceSpecial case.
What should have happened instead?:
Snappier response.
Software version
AWB 6.5.0.0 and 6.4.0.0.
Other information (browser name/version, screenshots, etc.):
Some profiling shows two major choke points; there may be others. The ListBox2.RemoveSelected method uses in-memory manipulation and a complete reload when operating on lists >= 500 long. This was introduced in SVN 12716. But most of the cases in practice only have one item selected, and the ListBox.RemoveAt method is very efficient. To be fair, the ListBox code may have been rewritten since Framework 4.5.2. A quick fix would be to just use RemoveAt for the one-item path; on a set of tests that results in a 26x speedup. The other cases would require considerable profiling to see where the tradeoff with in-memory technique happens. By the way, the LINQ operations can be optimized a little.
The other is the code that finds the longest article name in order to size the horizontal scrollbar, which is run every time a single item is drawn, even though the longest name rarely changes. To check the longest name when an article is added or removed from the list sounds attractive, but that would require subclassing ListBox.ObjectCollection, which is surprisingly difficult, or maybe use a DataSource (which fires change events). Just simplifying the LINQ code in the redraw results in a more than 6x speedup for the whole redraw method.
In ReplaceSpecial, the slow population of the tree redraw is slightly mitigated by using BeginUpdate/EndUpdate for the paste.
So I propose checking in the simple fixes and putting more fundamental logic changes on the backlog.