extend/cowboy — pull request #197 by klaar (2012-04-14 23:09:34+00:00)
Title: Return full packet as multipart body if possible

A small optimization to the multipart parser. A sub-binary the same size as the boundary string was cut off the end of each input binary while the parser was in the `parse_body` state to ensure that any partial boundary string occuring at the end of in the input is not missed. This sub-binary and the next input had to be concatenated for all inputs while in the `parse_body` state.

These changes adds a suffix matching function to reliably determine if a partial boundary string may occur at the end of the input. This avoids having to concatenate the two binaries unless it is absolutely necessary. For large multipart bodies this yields a 25% to 50% performance increase (depending on how you measure it).