Commit de87724a7e5dfb23193f8adb897164c9c31575c4
1 parent
d3072e9c
Optimize topicsMatch() a bit
Showing
1 changed file
with
4 additions
and
3 deletions
utils.cpp
| ... | ... | @@ -57,7 +57,8 @@ std::list<std::string> split(const std::string &input, const char sep, size_t ma |
| 57 | 57 | return list; |
| 58 | 58 | } |
| 59 | 59 | |
| 60 | - | |
| 60 | +thread_local std::vector<std::string> subscribeParts; | |
| 61 | +thread_local std::vector<std::string> publishParts; | |
| 61 | 62 | bool topicsMatch(const std::string &subscribeTopic, const std::string &publishTopic) |
| 62 | 63 | { |
| 63 | 64 | if (subscribeTopic.find("+") == std::string::npos && subscribeTopic.find("#") == std::string::npos) |
| ... | ... | @@ -66,8 +67,8 @@ bool topicsMatch(const std::string &subscribeTopic, const std::string &publishTo |
| 66 | 67 | if (!subscribeTopic.empty() && !publishTopic.empty() && publishTopic[0] == '$' && subscribeTopic[0] != '$') |
| 67 | 68 | return false; |
| 68 | 69 | |
| 69 | - std::vector<std::string> subscribeParts; | |
| 70 | - std::vector<std::string> publishParts; | |
| 70 | + subscribeParts.clear(); | |
| 71 | + publishParts.clear(); | |
| 71 | 72 | |
| 72 | 73 | #ifdef __SSE4_2__ |
| 73 | 74 | simdUtils.splitTopic(subscribeTopic, subscribeParts); | ... | ... |