-
Notifications
You must be signed in to change notification settings - Fork 24
/
Copy paththreadlocalutils.h
45 lines (31 loc) · 1.01 KB
/
threadlocalutils.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
This file is part of FlashMQ (https://www.flashmq.org)
Copyright (C) 2021-2023 Wiebe Cazemier
FlashMQ is free software: you can redistribute it and/or modify
it under the terms of The Open Software License 3.0 (OSL-3.0).
See LICENSE for license details.
*/
#ifndef THREADLOCALUTILS_H
#define THREADLOCALUTILS_H
#ifdef __SSE4_2__
#include <vector>
#include <array>
#include <string>
#include <immintrin.h>
#define TOPIC_MEMORY_LENGTH 65560
class SimdUtils
{
alignas(64) std::array<char, TOPIC_MEMORY_LENGTH> topicCopy;
__m128i slashes = _mm_set1_epi8('/');
__m128i lowerBound = _mm_set1_epi8(0x20);
__m128i lastAsciiChar = _mm_set1_epi8(0x7E);
__m128i non_ascii_mask = _mm_set1_epi8(0b10000000);
__m128i pound = _mm_set1_epi8('#');
__m128i plus = _mm_set1_epi8('+');
public:
SimdUtils() = default;
std::vector<std::string> splitTopic(const std::string &topic);
bool isValidUtf8(const std::string &s, bool alsoCheckInvalidPublishChars = false);
};
#endif
#endif // THREADLOCALUTILS_H