Boost logo

Boost :

Subject: Re: [boost] [beast] Formal review
From: Phil Endecott (spam_from_boost_dev_at_[hidden])
Date: 2017-07-10 16:57:16


Vinnie Falco wrote:
> The utf-8 validation of text websocket message payloads is a critical
> bottleneck.

I thought I'd have a look at that. Your code has a fast-path that
attempts to check 8 bytes at a time by masking with 0x8080808080808080.
I agree that that is probably a useful optimisation which a compiler is
unlikely to apply by itself. Your implementation
(
https://github.com/vinniefalco/Beast/blob/6f88f0182d461e9cabe55032f966c9ca4f77bf46/include/beast/websocket/detail/utf8_checker.hpp
) does this:

   if((*reinterpret_cast<std::size_t const*>(in) & mask) != 0)

So you're reinterpret_casting a char* to a size_t* and then dereferencing
it. Isn't that undefined behaviour?

Regards, Phil.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk