|********************************************|
|   Improvemnts used when creating           |
|   PURE Internet Relay Chat daemon          |
|  Created by Dilligent on 1/15/2003 12:30   |
|     PURE can be obtained from              |
| http://sourceforge.net/projects/pure-ircd/ |
**********************************************

1.  when checking a string against "" it is common to write:
        if string = ""
    but thats still slower than
        if len(string) = 0

2.  avoid using strings directly, rather use numbers.

3.  when checking if two strings are equal, it is common to write:
        if string1 = string2
    but thats slower than
        if strcomp(string1,string2) = 0
    (strcmp api is slower than both of these combined because of the string conversions vb does when calling api's)

4.  the "smallest" variable type in vb is "byte" because it only consumes one byte in memory
    therefor variables not used often or which only hold very low values should be of
    byte datatype to avoid hogging memory resources.

5.  Although "byte" saves memory, it wastes cpu cycles, the fastest variable type
    for numbers in vb is "long". Internally, if you (for example) compare two numbers,
    vb will convert both numbers to 32-bit (which in turn is "long"), thats not only for
    comparisons though, it's like that for all kinds of actions where a variable of numeric type
    is involved. "long" uses up 4 bytes though, this *does* make a difference in servers!

6.  Instead of writing large scaled "if...elseif...end if" statements, use "select case...case...end select".
    It runs faster than an "if" statement (although i can't imagine how that is achieved, it is that way).

7.  This applies to "If...end if" statements as well as to "Select case...end select":
    always put the most common case/elseif at the top because the system will have to do less checks this way.

8.  Use the Mid$, Ucase$, Lcase$, left$, right$ (...) functions instead of the ones without the "$" because those
    will use strings instead of Variants (!). ever noticed that the functions without "$" dont have an datatype?
    by default these use and return stuff as if they were variants and thus work much slower.

9.  okay, this is hard to explain so look at the example:
        If var1 = "" and var2 <> "" then
            '....abitrary code
        end if
    this is bad because it checks var1 AND var2 although that is maybe not nessacery, use this instead:
        If var1 = "" then
            if var2 <> "" then
                '....abitrary code
            end if
        end if
    This only does one check and if required it does the other check, this runs 2X faster.

10. Generally functions with "On Error Resume Next" in them run slower because vb will look for errors after
    every command executed and if there is one it skips the errourness line, so if possible avoid it and try to write bug-free code.

11. This goes without saying, always use "Option Explicit" at the top of *EACH* module. It forces you to declare all variables you use.

12. Avoid using ByVal variable passing, by default vb will pass variables ByRef anyway, ByVal forces it to create a copy
    of the variable passed and pass that instead, ByRef passes a reference, therefor running faster.

13. Avoid many memory allocations, for example "Redim Array(100)" will allocate 100 array elements, and allocating is slow.
    If possible "pre-allocate" (avoid having to resize something).

14. Again, hard to explain, look here:
        This is un-nessacerily slow:
            a = mid$(string,1,5)
            b = mid$(string,1,5)
            c = mid$(string,1,5)
        instead "cache" the result of 'mid$(string,1,5)' into a variable:
            Res = mid$(string,1,5)
            a=res
            b=res
            c=res
    This is a pretty stupid example but you got the idea.
 