Figure 10 Going low-level to improve efficiency

Figure 10a. Results of an inefficient += operator.

 1.0235   500  void PadWithSpaces(CString &str, int count)
              {
 5.0346 20000    while(count--)
30.0397 19000      str += " ";
 1.4354   500 }

Figure 10b. Improved performance with low-level C-strings.

 1.0235   500  void PadWithSpaces(CString &str, int count)
              {
 2.4505   500   char *tmp = new char[count+l];
 3.2930   500    memset(tmp,' ',count);
 0.9438   500    tmp[count] = '\0';
 5.3049   500    str += tmp;
 1.9430   500    delete[] tmp;
 1.4353   500 }

// End of File