Performance improvements

Dec 30, 2011 at 12:41 PM

Hi Neil,

nice to hear you want to get started with c# ;)

In your code, you extensively use the List<>.RemoveAt operation.
List<>.Remove and List<>.RemoveAt need a lot of time because they need to search through the whole list before they can remove an element. You will get much better performance by using an input and an output list, then just go through all elements in the input list and add them to your output list if they match your requirements.

Best regards,
Kc

Coordinator
Jan 3, 2012 at 10:03 PM

Thanks Kc.

I've made changes to some of the functions to include this suggestion and total running time is down from about 30 seconds a go to under 1. It also made me realise how incredibly lazy i'd been with one of my comparisons which has now been combined into a single if statement!

I've not worked on the inner part of the comparison loop which converts everything into char arrays for letter comparison but i'll think about that when I have a bit more time to get my brain into it.

Thanks again for your advice.

Neil