Represent tag name map as a std::map
This doesn't seem to affect performance, and unordered_map requires C++11.
This commit is contained in:
parent
331b0a4b00
commit
3ba95dbf3e
12
src/tag.h
12
src/tag.h
|
@ -1,8 +1,8 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <unordered_map>
|
#include <map>
|
||||||
|
|
||||||
using std::string;
|
using std::string;
|
||||||
using std::unordered_map;
|
using std::map;
|
||||||
|
|
||||||
enum TagType {
|
enum TagType {
|
||||||
AREA,
|
AREA,
|
||||||
|
@ -137,8 +137,8 @@ enum TagType {
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static const unordered_map<string, TagType> get_tag_map() {
|
static const map<string, TagType> get_tag_map() {
|
||||||
unordered_map<string, TagType> result;
|
map<string, TagType> result;
|
||||||
#define TAG(name) result[#name] = name
|
#define TAG(name) result[#name] = name
|
||||||
TAG(AREA);
|
TAG(AREA);
|
||||||
TAG(BASE);
|
TAG(BASE);
|
||||||
|
@ -269,7 +269,7 @@ static const unordered_map<string, TagType> get_tag_map() {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const unordered_map<string, TagType> TAG_TYPES_BY_TAG_NAME = get_tag_map();
|
static const map<string, TagType> TAG_TYPES_BY_TAG_NAME = get_tag_map();
|
||||||
|
|
||||||
static const TagType TAG_TYPES_NOT_ALLOWED_IN_PARAGRAPHS[] = {
|
static const TagType TAG_TYPES_NOT_ALLOWED_IN_PARAGRAPHS[] = {
|
||||||
ADDRESS,
|
ADDRESS,
|
||||||
|
@ -368,7 +368,7 @@ struct Tag {
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Tag for_name(const string &name) {
|
static inline Tag for_name(const string &name) {
|
||||||
unordered_map<string, TagType>::const_iterator type = TAG_TYPES_BY_TAG_NAME.find(name);
|
map<string, TagType>::const_iterator type = TAG_TYPES_BY_TAG_NAME.find(name);
|
||||||
if (type != TAG_TYPES_BY_TAG_NAME.end()) {
|
if (type != TAG_TYPES_BY_TAG_NAME.end()) {
|
||||||
return Tag(type->second, string());
|
return Tag(type->second, string());
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue