If you are looking for significant performance improvements, you want to try to do three things.
1. Improve the actual asymptotic runtime of your code.
2. Try to use built in functions instead of writing it in torque.
3. Cache stuff
To improve the asymptotic runtime of your code, you need to actually understand how algorithms work and how to determine if something can be done faster. For example, if you want to sort an array, you can easily do it by finding the largest number in O(n) time, then finding the next largest, and so on until the array is sorted. However, this results in O(n^2) runtime. If you implement a real sorting algorithm such as quicksort, you can do this in O(nlogn) time, which is much faster.
You really don't want to actually sort a large list using torquescript. TS is super slow. You should not write your own substring method when you can just use the built in getsubstr() method. Similarly, there is a built in sorting algorithm available to objects with the class GUITextListCtrl. Making a function that puts your data into a GUITextListCtrl and calls .sort() on it is much faster than actually sorting it yourself.
The easiest way to improve the speed of your code is to cache results that you know you will use over and over again. Torque global variables are hashed and don't really slow down even when when you are using millions of them. Go ahead and store whatever data you think might be useful in a $globalvar. However, using global objects is considerably slower.
You should absolutely NOT worry about the size of your source code. Trying to minimize your code just makes it harder for yourself and others to understand and maintain it later down the road.