Content deleted Content added
+{{essay-like}}{{unencyclopedic}} |
|||
Line 64:
== The Solution ==
Yep, Schlemiel would be well advised to "take your paint with you"... So how can we apply that principle to ''strcat''? Easy, we just have to remember the end of the string, to avoid
<source lang="c">
Line 83:
</source>
Our new ''szcat'' function is basically the same, it just returns the-new-end-of-the-destination-string instead of the-start-of-the-destination-string... So what? Well so the '''next time''' we call ''szcat'' we can pass it the-end-of-the-destination-string, so ''szcat'' doesn't have to waste time
<source lang="c">
Line 101:
</source>
The
* The number of times through the loop is still int(1024*1024/6) = 174,762 //
* We've eliminated the overhead of finding the-end-of-the-destination-string in the ''while'' condition
* We've eliminated the overhead of finding the-end-of-the-destination-string in ''strcat(endOfBuffer, word)'', which leaves is with just the cost of copying the string, which is 6 cycles per loop = 174,762 * 6 = 1,048,572
* about 1.2
*
== Conclusion ==
|