The key to making programs fast is to make them do practically nothing. 😉
via Mike Haertel on why GNU grep is fast, where he describes some of the tricks he used to minimize the amount of work grep needed to do in order to find strings. Mike wrote the original version of GNU grep.