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

@ -3,7 +3,7 @@
------------------------ --------------------------------- --------------------
Chapter 16\
There Ain’t No Such Thing as the Fastest Code {#Heading1}
There Ain't No Such Thing as the Fastest Code {#Heading1}
----------------------------------------------
### Lessons Learned in the Pursuit of the Ultimate Word Counter {#Heading2}
@ -34,15 +34,15 @@ importance to buyers:
**10.**  Windows development cycle automation
Is something missing here? You bet your maximum *gluteus* something’s
Is something missing here? You bet your maximum *gluteus* something's
missing—nowhere on that list is there so much as one word about how fast
the compiled code runs! I’m not saying that performance is everything,
but optimization isn’t even down there at number 10, below online help!
the compiled code runs! I'm not saying that performance is everything,
but optimization isn't even down there at number 10, below online help!
Ye gods and little fishes! We are talking here about people who would
take a bus from LA to New York instead of a plane because it had a
cleaner bathroom; who would choose a painting from a Holiday Inn over a
Matisse because it had a fancier frame; who would buy a Yugo instead
of—well, hell, anything—because it had a nice owner’s manual and
of—well, hell, anything—because it had a nice owner's manual and
particularly attractive keys. We are talking about people who are
focusing on means, and have forgotten about ends. We are talking about
people with no programming souls.
@ -53,7 +53,7 @@ What are we to make of this? At the very least, we can safely guess that
very few corporate buyers ever enter optimization contests. Most of my
readers do, however; in fact, far more than I thought ever would, but
that gladdens me to no end. I issued my first optimization challenge in
a “Pushing the Envelope” column in *PC TECHNIQUES* back in 1991, and was
a "Pushing the Envelope" column in *PC TECHNIQUES* back in 1991, and was
deluged by respondents who, one might also gather, do not live by *PC
Week*.
@ -64,11 +64,11 @@ optimization issues along the way. David did all his coding in Pascal,
pointing out that while an assembly language version would probably be
faster, his Pascal utility worked properly and was fast enough for him.
It wasn’t, however, fast enough for me. The logical starting place for
speeding up word counting would be David’s original Pascal code, but I’m
It wasn't, however, fast enough for me. The logical starting place for
speeding up word counting would be David's original Pascal code, but I'm
much more comfortable with C, so Listing 16.1 is a loose approximation
of David’s word count program, translated to C. I left out a few
details, such as handling comment blocks, partly because I don’t use
of David's word count program, translated to C. I left out a few
details, such as handling comment blocks, partly because I don't use
such blocks myself, and partly so we can focus on optimizing the core
word-counting code. As Table 16.1 indicates, Listing 16.1 counts the
words in a 104,448-word file in 4.6 seconds. The file was stored on a
@ -128,22 +128,22 @@ Table 16.1 Word count timings.
char *Buffer, CharFlag = 0, PredCharFlag, *BufferPtr, Ch;
if (argc != 2) {
printf(“usage: wc <filename>\n”);
printf("usage: wc <filename>\n");
exit(1);
}
if ((Buffer = malloc(BUFFER_SIZE)) == NULL) {
printf(“Can’t allocate adequate memory\n”);
printf("Can't allocate adequate memory\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 ((FileSize = filelength(Handle)) == -1) {
printf(“Error sizing file %s\n”, argv[1]);
printf("Error sizing file %s\n", argv[1]);
exit(1);
}
@ -152,7 +152,7 @@ Table 16.1 Word count timings.
/* Get the next chunk */
FileSize -= (BlockSize = min(FileSize, BUFFER_SIZE));
if (read(Handle, Buffer, BlockSize) == -1) {
printf(“Error reading file %s\n”, argv[1]);
printf("Error reading file %s\n", argv[1]);
exit(1);
}
/* Count words in the chunk */
@ -162,10 +162,10 @@ Table 16.1 Word count timings.
Ch = *BufferPtr++ & 0x7F; /* strip high bit, which some
word processors set as an
internal flag */
CharFlag = ((Ch >= ‘a’) && (Ch <= ‘z’)) ||
((Ch >= ‘A’) && (Ch <= ‘Z’)) ||
((Ch >= ‘0’) && (Ch <= ‘9’)) ||
(Ch == ‘\’’);
CharFlag = ((Ch >= ‘a') && (Ch <= ‘z')) ||
((Ch >= ‘A') && (Ch <= ‘Z')) ||
((Ch >= ‘0') && (Ch <= ‘9')) ||
(Ch == ‘\'');
if ((!CharFlag) && PredCharFlag) {
WordCo u nt++;
}
@ -176,7 +176,7 @@ Table 16.1 Word count timings.
if (CharFlag) {
WordCount++;
}
printf(“\nTotal words in file: %lu\n”, WordCount);
printf("\nTotal words in file: %lu\n", WordCount);
return(0);
}