Use backtick code blocks for syntax highlighting

This commit is contained in:
James Gregory 2013-12-31 11:38:48 +11:00
commit f658bfbb40
203 changed files with 26546 additions and 25801 deletions

View file

@ -56,38 +56,42 @@ Second, when performance matters, never have your code perform the same
calculation more than once. This sounds obvious, but it's astonishing
how often it's ignored. For example, consider this snippet of code:
for (i=0; i<RunLength; i++)
{
*WorkingScreenPtr = Color;
if (XDelta > 0)
{
WorkingScreenPtr++;
}
else
{
WorkingScreenPtr--;
}
}
```cpp
for (i=0; i<RunLength; i++)
{
*WorkingScreenPtr = Color;
if (XDelta > 0)
{
WorkingScreenPtr++;
}
else
{
WorkingScreenPtr--;
}
}
```
Here, the programmer knows which way the line is going before the main
loop begins—but nonetheless performs that test every time through the
loop, when calculating the address of the next pixel. Far better to
perform the test only once, outside the loop, as shown here:
if (XDelta > 0)
{
for (i=0; i<RunLength; i++)
{
*WorkingScreenPtr++ = Color;
}
}
else
{
for (i=0; i<RunLength; i++)
{
*WorkingScreenPtr-- = Color;
}
}
```cpp
if (XDelta > 0)
{
for (i=0; i<RunLength; i++)
{
*WorkingScreenPtr++ = Color;
}
}
else
{
for (i=0; i<RunLength; i++)
{
*WorkingScreenPtr-- = Color;
}
}
```
Think of it this way: A program is a state machine. It takes a set of
inputs and produces a corresponding set of outputs by passing through a