Normal quotes

This commit is contained in:
James Gregory 2013-12-30 18:34:31 +11:00
commit 18011c595a
352 changed files with 6040 additions and 6040 deletions

View file

@ -86,11 +86,11 @@ Ratio best\
57.44
**Note:** The execution times (in seconds) for this chapter’s listings
**Note:** The execution times (in seconds) for this chapter's listings
were timed when the compiled listings were run on the WordPerfect 4.2
thesaurus file TH.WP (362,293 bytes in size), as compiled in the small
model with Borland and Microsoft compilers with optimization on (opt)
and off (no opt). All times were measured with Paradigm Systems’ TIMER
and off (no opt). All times were measured with Paradigm Systems' TIMER
program on a 10 MHz 1-wait-state AT clone with a 28-ms hard disk, with
disk caching turned off.
@ -118,20 +118,20 @@ Table 1.1 Execution Times for WordPerfect Checksum.
int ReadLength;
if ( argc != 2 ) {
printf(“usage: checksum filename\n”);
printf("usage: checksum filename\n");
exit(1);
}
if ( (Handle = open(argv[1], O_RDONLY | O_BINARY)) == -1 ) {
printf(“Can’t open file: %s\n”, argv[1]);
printf("Can't open file: %s\n", argv[1]);
exit(1);
}
if ( !ChecksumFile(Handle, &Checksum) ) {
printf(“Error reading file %s\n”, argv[1]);
printf("Error reading file %s\n", argv[1]);
exit(1);
}
/* Report the result */
printf(“The checksum is: %u\n”, Checksum);
printf("The checksum is: %u\n", Checksum);
exit(0);
}
@ -170,7 +170,7 @@ Table 1.1 Execution Times for WordPerfect Checksum.
_ChecksumFile proc near
push bp
mov bp,sp
push si ;save C’s register variable
push si ;save C's register variable
;
mov bx,[bp+Handle] ;get file handle
sub si,si ;zero the checksum ;accumulator
@ -183,7 +183,7 @@ Table 1.1 Execution Times for WordPerfect Checksum.
int 21h ;read the byte
jcErrorEnd;an error occurred
and ax,ax ;any bytes read?
jz Success ;no-end of file reached-we’re done
jz Success ;no-end of file reached-we're done
add si,[TempWord] ;add the byte into the
;checksum total
jmpChecksumLoop
@ -196,7 +196,7 @@ Table 1.1 Execution Times for WordPerfect Checksum.
mov ax,1 ;success
;
Done:
pop si ;restore C’s register variable
pop si ;restore C's register variable
pop bp
ret
_ChecksumFileendp
@ -206,7 +206,7 @@ The lesson is clear: Optimization makes code faster, but without proper
design, optimization just creates fast slow code.
Well, then, how are we going to improve our design? Before we can do
that, we have to understand what’s wrong with the current design.
that, we have to understand what's wrong with the current design.
#### Know the Territory {#Heading9}
@ -229,17 +229,17 @@ a *long* time—far, far longer than the rest of the main loop in Listing
**read(),** and most of that time is spent somewhere down in DOS.
You can verify this for yourself by watching the code with a debugger or
using a code profiler, but take my word for it: There’s a great deal of
overhead to DOS calls, and that’s what’s draining the life out of
using a code profiler, but take my word for it: There's a great deal of
overhead to DOS calls, and that's what's draining the life out of
Listing 1.1.
How can we speed up Listing 1.1? It should be clear that we must somehow
avoid invoking DOS for every byte in the file, and that means reading
more than one byte at a time, then buffering the data and parceling it
out for examination one byte at a time. By gosh, that’s a description of
C’s stream I/O feature, whereby C reads files in chunks and buffers the
out for examination one byte at a time. By gosh, that's a description of
C's stream I/O feature, whereby C reads files in chunks and buffers the
bytes internally, doling them out to the application as needed by
reading them from memory rather than calling DOS. Let’s try using stream
reading them from memory rather than calling DOS. Let's try using stream
I/O and see what happens.
Listing 1.4 is similar to Listing 1.1, but uses **fopen()** and