Skip to content

Commit

Permalink
Fix strict weak ordering requirements
Browse files Browse the repository at this point in the history
  • Loading branch information
uNetworkingAB committed Dec 4, 2024
1 parent 9c45399 commit 468f5c8
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/HttpRouter.h
Original file line number Diff line number Diff line change
Expand Up @@ -302,14 +302,13 @@ struct HttpRouter {

/* ANY method must be last, GET must be first */
std::sort(root.children.begin(), root.children.end(), [](const auto &a, const auto &b) {
/* Assuming the list of methods is unique, non-repeating */
if (a->name == "GET") {
if (a->name == "GET" && b->name != "GET") {
return true;
} else if (b->name == "GET") {
} else if (b->name == "GET" && a->name != "GET") {
return false;
} else if (a->name == ANY_METHOD_TOKEN) {
} else if (a->name == ANY_METHOD_TOKEN && b->name != ANY_METHOD_TOKEN) {
return false;
} else if (b->name == ANY_METHOD_TOKEN) {
} else if (b->name == ANY_METHOD_TOKEN && a->name != ANY_METHOD_TOKEN) {
return true;
} else {
return a->name < b->name;
Expand Down
2 changes: 1 addition & 1 deletion tests/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ default:
./ChunkedEncoding
$(CXX) -std=c++17 -fsanitize=address TopicTree.cpp -o TopicTree
./TopicTree
$(CXX) -std=c++17 -fsanitize=address HttpRouter.cpp -o HttpRouter
$(CXX) -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_DEBUG -std=c++17 -fsanitize=address HttpRouter.cpp -o HttpRouter
./HttpRouter
$(CXX) -std=c++17 -fsanitize=address BloomFilter.cpp -o BloomFilter
./BloomFilter
Expand Down

0 comments on commit 468f5c8

Please sign in to comment.