Previously it would do a character by character search for a null terminator, to account for the fact that an arbitrary stream need not store its data contiguously so you couldn't just do a memchr. However, the stream API has a function which will return the longest contiguous chunk without doing a copy, and by using this function we can do a memchr on the individual chunks. For certain types of streams like data from object files etc, this is guaranteed to find the null terminator with only a single memchr, but even with discontiguous streams such as MappedBlockStream, it's rare that any given string will cross a block boundary, so even those will almost always be satisfied with a single memchr.
This optimization is worth a 10-12% reduction in link time (4.2 seconds -> 3.75 seconds)
How about S = S.take_front(strnlen(S.data(), S.size()))? There are some neat tricks for making strlen fast that don't work for memchr.