17
17
18
18
#include < cstddef>
19
19
#include < memory>
20
- #include < set>
21
20
#include < sstream>
22
21
#include < string>
23
22
#include < unordered_map>
23
+ #include < unordered_set>
24
24
25
25
#include " http_template.h"
26
26
#include " path_matcher_node.h"
@@ -71,13 +71,13 @@ class PathMatcher {
71
71
// registered to this node.
72
72
std::unique_ptr<PathMatcherNode> root_ptr_;
73
73
// Holds the set of custom verbs found in configured templates.
74
- std::set <std::string> custom_verbs_;
74
+ std::unordered_set <std::string> custom_verbs_;
75
75
// Data we store per each registered method
76
76
struct MethodData {
77
77
Method method;
78
78
std::vector<HttpTemplate::Variable> variables;
79
79
std::string body_field_path;
80
- std::set <std::string> system_query_parameter_names;
80
+ std::unordered_set <std::string> system_query_parameter_names;
81
81
};
82
82
// The info associated with each method. The path matcher nodes
83
83
// will hold pointers to MethodData objects in this vector.
@@ -105,10 +105,11 @@ class PathMatcherBuilder {
105
105
// Registrations are one-to-one. If this function is called more than once, it
106
106
// replaces the existing method. Only the last registered method is stored.
107
107
// Return false if path is an invalid http template.
108
- bool Register (const std::string& http_method, const std::string& path,
109
- const std::string& body_field_path,
110
- const std::set<std::string>& system_query_parameter_names,
111
- Method method);
108
+ bool Register (
109
+ const std::string& http_method, const std::string& path,
110
+ const std::string& body_field_path,
111
+ const std::unordered_set<std::string>& system_query_parameter_names,
112
+ Method method);
112
113
bool Register (const std::string& http_method, const std::string& path,
113
114
const std::string& body_field_path, Method method);
114
115
@@ -129,7 +130,7 @@ class PathMatcherBuilder {
129
130
// TODO: Perhaps this should not be at this level because there will
130
131
// be multiple templates in different services on a server. Consider moving
131
132
// this to PathMatcherNode.
132
- std::set <std::string> custom_verbs_;
133
+ std::unordered_set <std::string> custom_verbs_;
133
134
typedef typename PathMatcher<Method>::MethodData MethodData;
134
135
std::vector<std::unique_ptr<MethodData>> methods_;
135
136
@@ -291,7 +292,8 @@ void ExtractBindingsFromPath(const std::vector<HttpTemplate::Variable>& vars,
291
292
292
293
template <class VariableBinding >
293
294
void ExtractBindingsFromQueryParameters (
294
- const std::string& query_params, const std::set<std::string>& system_params,
295
+ const std::string& query_params,
296
+ const std::unordered_set<std::string>& system_params,
295
297
std::vector<VariableBinding>* bindings) {
296
298
// The bindings in URL the query parameters have the following form:
297
299
// <field_path1>=value1&<field_path2>=value2&...&<field_pathN>=valueN
@@ -476,7 +478,8 @@ template <class Method>
476
478
bool PathMatcherBuilder<Method>::Register(
477
479
const std::string& http_method, const std::string& http_template,
478
480
const std::string& body_field_path,
479
- const std::set<std::string>& system_query_parameter_names, Method method) {
481
+ const std::unordered_set<std::string>& system_query_parameter_names,
482
+ Method method) {
480
483
std::unique_ptr<HttpTemplate> ht (HttpTemplate::Parse (http_template));
481
484
if (nullptr == ht) {
482
485
return false ;
0 commit comments