Skip to content

Commit 22d14c8

Browse files
author
Kyu Hyun Chang
committed
Replace std::set with std::unordered_set in path matcher utility
1 parent ba83152 commit 22d14c8

File tree

2 files changed

+21
-21
lines changed

2 files changed

+21
-21
lines changed

src/include/grpc_transcoding/path_matcher_utility.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ class PathMatcherUtility {
2828
template <class Method>
2929
static bool RegisterByHttpRule(
3030
PathMatcherBuilder<Method> &pmb, const google::api::HttpRule &http_rule,
31-
const std::set<std::string> &system_query_parameter_names,
31+
const std::unordered_set<std::string> &system_query_parameter_names,
3232
const Method &method);
3333

3434
template <class Method>
@@ -42,7 +42,7 @@ class PathMatcherUtility {
4242
template <class Method>
4343
bool PathMatcherUtility::RegisterByHttpRule(
4444
PathMatcherBuilder<Method> &pmb, const google::api::HttpRule &http_rule,
45-
const std::set<std::string> &system_query_parameter_names,
45+
const std::unordered_set<std::string> &system_query_parameter_names,
4646
const Method &method) {
4747
bool ok = true;
4848
switch (http_rule.pattern_case()) {

test/path_matcher_utility_test.cc

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class PathMatcherBuilder<const TestMethod*> {
3737
public:
3838
MOCK_METHOD5(Register,
3939
bool(const std::string&, const std::string&, const std::string&,
40-
const std::set<std::string>&, const TestMethod*));
40+
const std::unordered_set<std::string>&, const TestMethod*));
4141
};
4242
}
4343
}
@@ -64,12 +64,12 @@ TEST_F(PathMatcherUtilityTest, RegisterGet) {
6464
http_rule.set_get("/path");
6565
http_rule.set_body("body");
6666
EXPECT_CALL(pmb, Register(Eq("GET"), Eq("/path"), Eq("body"),
67-
Eq(std::set<std::string>()), Eq(&method1_)))
67+
Eq(std::unordered_set<std::string>()), Eq(&method1_)))
6868
.WillOnce(Return(true));
6969
ASSERT_TRUE(
7070
PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, &method1_));
7171
EXPECT_CALL(pmb, Register(Eq("GET"), Eq("/path"), Eq("body"),
72-
Eq(std::set<std::string>{"key"}), Eq(&method2_)))
72+
Eq(std::unordered_set<std::string>{"key"}), Eq(&method2_)))
7373
.WillOnce(Return(false));
7474
ASSERT_FALSE(PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, {"key"},
7575
&method2_));
@@ -80,12 +80,12 @@ TEST_F(PathMatcherUtilityTest, RegisterPut) {
8080
http_rule.set_put("/path");
8181
http_rule.set_body("body");
8282
EXPECT_CALL(pmb, Register(Eq("PUT"), Eq("/path"), Eq("body"),
83-
Eq(std::set<std::string>()), Eq(&method1_)))
83+
Eq(std::unordered_set<std::string>()), Eq(&method1_)))
8484
.WillOnce(Return(true));
8585
ASSERT_TRUE(
8686
PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, &method1_));
8787
EXPECT_CALL(pmb, Register(Eq("PUT"), Eq("/path"), Eq("body"),
88-
Eq(std::set<std::string>{"key"}), Eq(&method2_)))
88+
Eq(std::unordered_set<std::string>{"key"}), Eq(&method2_)))
8989
.WillOnce(Return(false));
9090
ASSERT_FALSE(PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, {"key"},
9191
&method2_));
@@ -96,12 +96,12 @@ TEST_F(PathMatcherUtilityTest, RegisterPost) {
9696
http_rule.set_post("/path");
9797
http_rule.set_body("body");
9898
EXPECT_CALL(pmb, Register(Eq("POST"), Eq("/path"), Eq("body"),
99-
Eq(std::set<std::string>()), Eq(&method1_)))
99+
Eq(std::unordered_set<std::string>()), Eq(&method1_)))
100100
.WillOnce(Return(true));
101101
ASSERT_TRUE(
102102
PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, &method1_));
103103
EXPECT_CALL(pmb, Register(Eq("POST"), Eq("/path"), Eq("body"),
104-
Eq(std::set<std::string>{"key"}), Eq(&method2_)))
104+
Eq(std::unordered_set<std::string>{"key"}), Eq(&method2_)))
105105
.WillOnce(Return(false));
106106
ASSERT_FALSE(PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, {"key"},
107107
&method2_));
@@ -112,12 +112,12 @@ TEST_F(PathMatcherUtilityTest, RegisterDelete) {
112112
http_rule.set_delete_("/path");
113113
http_rule.set_body("body");
114114
EXPECT_CALL(pmb, Register(Eq("DELETE"), Eq("/path"), Eq("body"),
115-
Eq(std::set<std::string>()), Eq(&method1_)))
115+
Eq(std::unordered_set<std::string>()), Eq(&method1_)))
116116
.WillOnce(Return(true));
117117
ASSERT_TRUE(
118118
PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, &method1_));
119119
EXPECT_CALL(pmb, Register(Eq("DELETE"), Eq("/path"), Eq("body"),
120-
Eq(std::set<std::string>{"key"}), Eq(&method2_)))
120+
Eq(std::unordered_set<std::string>{"key"}), Eq(&method2_)))
121121
.WillOnce(Return(false));
122122
ASSERT_FALSE(PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, {"key"},
123123
&method2_));
@@ -128,12 +128,12 @@ TEST_F(PathMatcherUtilityTest, RegisterPatch) {
128128
http_rule.set_patch("/path");
129129
http_rule.set_body("body");
130130
EXPECT_CALL(pmb, Register(Eq("PATCH"), Eq("/path"), Eq("body"),
131-
Eq(std::set<std::string>()), Eq(&method1_)))
131+
Eq(std::unordered_set<std::string>()), Eq(&method1_)))
132132
.WillOnce(Return(true));
133133
ASSERT_TRUE(
134134
PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, &method1_));
135135
EXPECT_CALL(pmb, Register(Eq("PATCH"), Eq("/path"), Eq("body"),
136-
Eq(std::set<std::string>{"key"}), Eq(&method2_)))
136+
Eq(std::unordered_set<std::string>{"key"}), Eq(&method2_)))
137137
.WillOnce(Return(false));
138138
ASSERT_FALSE(PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, {"key"},
139139
&method2_));
@@ -145,12 +145,12 @@ TEST_F(PathMatcherUtilityTest, RegisterCustom) {
145145
http_rule.mutable_custom()->set_path("/custom_path");
146146
http_rule.set_body("body");
147147
EXPECT_CALL(pmb, Register(Eq("OPTIONS"), Eq("/custom_path"), Eq("body"),
148-
Eq(std::set<std::string>()), Eq(&method1_)))
148+
Eq(std::unordered_set<std::string>()), Eq(&method1_)))
149149
.WillOnce(Return(true));
150150
ASSERT_TRUE(
151151
PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, &method1_));
152152
EXPECT_CALL(pmb, Register(Eq("OPTIONS"), Eq("/custom_path"), Eq("body"),
153-
Eq(std::set<std::string>{"key"}), Eq(&method2_)))
153+
Eq(std::unordered_set<std::string>{"key"}), Eq(&method2_)))
154154
.WillOnce(Return(false));
155155
ASSERT_FALSE(PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, {"key"},
156156
&method2_));
@@ -174,25 +174,25 @@ TEST_F(PathMatcherUtilityTest, RegisterAdditionalBindings) {
174174
custom_http_rule3.set_put("/put_path");
175175

176176
EXPECT_CALL(pmb, Register(Eq("GET"), Eq("/path"), Eq("body"),
177-
Eq(std::set<std::string>()), Eq(&method1_)))
177+
Eq(std::unordered_set<std::string>()), Eq(&method1_)))
178178
.WillOnce(Return(true));
179179
EXPECT_CALL(pmb, Register(Eq("OPTIONS"), Eq("/custom_path"), Eq("body1"),
180-
Eq(std::set<std::string>()), Eq(&method1_)))
180+
Eq(std::unordered_set<std::string>()), Eq(&method1_)))
181181
.WillOnce(Return(true));
182182
EXPECT_CALL(pmb, Register(Eq("HEAD"), Eq("/path"), Eq(""),
183-
Eq(std::set<std::string>()), Eq(&method1_)))
183+
Eq(std::unordered_set<std::string>()), Eq(&method1_)))
184184
.WillOnce(Return(true));
185185
EXPECT_CALL(pmb, Register(Eq("PUT"), Eq("/put_path"), Eq(""),
186-
Eq(std::set<std::string>()), Eq(&method1_)))
186+
Eq(std::unordered_set<std::string>()), Eq(&method1_)))
187187
.WillOnce(Return(true));
188188
ASSERT_TRUE(
189189
PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, &method1_));
190190

191191
EXPECT_CALL(pmb, Register(Eq("GET"), Eq("/path"), Eq("body"),
192-
Eq(std::set<std::string>{"key"}), Eq(&method2_)))
192+
Eq(std::unordered_set<std::string>{"key"}), Eq(&method2_)))
193193
.WillOnce(Return(true));
194194
EXPECT_CALL(pmb, Register(Eq("OPTIONS"), Eq("/custom_path"), Eq("body1"),
195-
Eq(std::set<std::string>{"key"}), Eq(&method2_)))
195+
Eq(std::unordered_set<std::string>{"key"}), Eq(&method2_)))
196196
.WillOnce(Return(false));
197197
ASSERT_FALSE(PathMatcherUtility::RegisterByHttpRule(pmb, http_rule, {"key"},
198198
&method2_));

0 commit comments

Comments
 (0)