Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/WebSocketProtocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@
#include <cstdlib>
#include <string_view>

#ifdef UWS_USE_SIMDUTF
#include <simdutf.h>
#endif

namespace uWS {

/* We should not overcomplicate these */
Expand Down Expand Up @@ -111,6 +115,14 @@ T cond_byte_swap(T value) {
return value;
}

#ifdef UWS_USE_SIMDUTF

static bool isValidUtf8(unsigned char *s, size_t length)
{
return simdutf::validate_utf8((const char *)s, length);
}

#else
// Based on utf8_check.c by Markus Kuhn, 2005
// https://www.cl.cam.ac.uk/~mgk25/ucs/utf8_check.c
// Optimized for predominantly 7-bit content by Alex Hultman, 2016
Expand Down Expand Up @@ -158,6 +170,8 @@ static bool isValidUtf8(unsigned char *s, size_t length)
return true;
}

#endif

struct CloseFrame {
uint16_t code;
char *message;
Expand Down
Loading