Okay, I have a TListBox that on occasion may be called upon to show 43,000 lines!
I know, this hardly ever makes any sense, but there it is.
Now here's the current problem:
Using the built-in Sort method, with its Compare callback function, takes nearly forever, like many minutes.
So I extract the strings out of the listbox into a plain old dynamic array of ShortStrintgs, do a QuickSort() on that, and that takes about three seconds. Whopee I think!
Doing a bit of thinking, I see that QuickSort is moving all those strings around, which there is no need for, so I cange the code to just move around pointers or indices to the strings, and voila, the sort is much faster again, takin under a second to sort 43,000 items. Big win, yes?
BUT, now if I do a LB.Items.Add() or LB.Items.Assign to move the sorted strings into the listbox, THAT takes like 30 seconds! Even with BEgin/EndUpdate happening. If I trace through the code I see a whole lot of stuff going on with delete() Insert() INsertObject() and Windows messages flying for no good reason.
A moment's though reveals that I HAVE all the strings in the LB.TStrings, I just need them shuffled around ala my QuickSorted() array. That should be trivial, just moving some pointers.
But I don't see any visible way to set the raw TStringList pointers. No, Exchange() is really really slow.
Any ideas how I can get to the TString string pointers? This should be trivial but I don't see it.
Thanks,
George