1
0
mirror of https://github.com/OlafvdSpek/ctemplate.git synced 2025-09-28 19:05:49 +08:00

Use count instead of find

This commit is contained in:
olafvdspek@gmail.com 2012-12-19 08:07:45 +00:00
parent df11656259
commit c758930da8
2 changed files with 6 additions and 6 deletions

View File

@ -500,12 +500,12 @@ void HtmlparserCppTest::ProcessAnnotation(const string &annotation) {
} else if (iter->first.compare("is_url_start") == 0) {
ValidateIsUrlStart(iter->second);
} else if (iter->first.compare("save_context") == 0) {
if (contextMap.find(iter->second) == contextMap.end()) {
if (!contextMap.count(iter->second)) {
contextMap[iter->second] = new HtmlParser();
}
contextMap[iter->second]->CopyFrom(&parser_);
} else if (iter->first.compare("load_context") == 0) {
CHECK(contextMap.find(iter->second) != contextMap.end());
CHECK(contextMap.count(iter->second));
parser_.CopyFrom(contextMap[iter->second]);
} else if (iter->first.compare("reset") == 0) {
if (StringToBool(iter->second)) {

View File

@ -1455,10 +1455,10 @@ TEST(Template, TemplateNamelist) {
TemplateNamelist::NameListType names = TemplateNamelist::GetList();
ASSERT(names.size() == 4);
ASSERT(names.find(NONEXISTENT_FN) != names.end());
ASSERT(names.find(INVALID1_FN) != names.end());
ASSERT(names.find(INVALID2_FN) != names.end());
ASSERT(names.find(VALID1_FN) != names.end());
ASSERT(names.count(NONEXISTENT_FN));
ASSERT(names.count(INVALID1_FN));
ASSERT(names.count(INVALID2_FN));
ASSERT(names.count(VALID1_FN));
// Before creating the files INVALID1_FN, etc., all should be missing.
for (int i = 0; i < 3; ++i) { // should be consistent all 3 times