I'm looking into slow results from a search and it seems that the most time is spent in search_excerpt(). In particular, the line: if (preg_match('/'. $boundary . $key . $boundary .'/iu', $text, $match, PREG_OFFSET_CAPTURE, $included[$key])). I'm not sure I understand the need for $boundry. Removing it makes the search much faster.

What's the reason for it? If the search key is known to be in $text, why not search for just the key?