switched delphi keyword tables from map to set and array init
diff --git a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
index de7e46a..4264d85 100644
--- a/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_delphi_generator.cc
@@ -45,6 +45,7 @@
 #endif
 
 using std::map;
+using std::set;
 using std::ofstream;
 using std::ostream;
 using std::ostringstream;
@@ -405,20 +406,59 @@
   bool has_enum;
   bool has_const;
   std::string namespace_dir_;
-  std::map<std::string, int> delphi_keywords;  // TODO: put all into one map, value=flags tells what it is
-  std::map<std::string, int> delphi_reserved_names;
-  std::map<std::string, int> delphi_reserved_method;
-  std::map<std::string, int> delphi_reserved_method_exception;
-  std::map<std::string, int> types_known;
+  std::set<std::string> types_known;
   std::list<t_typedef*> typedefs_pending;
   std::vector<std::string> uses_list;
-  void create_keywords();
-  bool find_keyword(std::map<std::string, int>& keyword_map, std::string name);
+  std::string empty_value(t_type* type);
+
+  const std::string DELPHI_KEYWORDS[81] = {
+    // keywords
+    "and", "array", "as", "asm", "at", "automated", "begin", "case", "class", "const", "constructor", 
+    "destructor", "dispinterface", "div", "do", "downto", "else", "end", "except", "exports", "file", 
+    "finalization", "finally", "for", "function", "goto", "if", "implementation", "in", "inherited", 
+    "initialization", "inline", "interface", "is", "label", "library", "mod", "nil", "not", "object", 
+    "of", "on", "or", "out", "packed", "private", "procedure", "program", "property", "protected", 
+    "public", "published", "raise", "record", "repeat", "resourcestring", "set", "shl", "shr", "string", 
+    "then", "threadvar", "to", "try", "type", "unit", "until", "uses", "var", "while", "with", "xor",
+    // predefined types (lowercase!)
+    "ansistring", "boolean", "double", "int64", "integer", "shortint", "smallint", "string", "unicodestring"
+  };
+
+  // reserved variables and types (lowercase!)
+  const std::string DELPHI_RESERVED_NAMES[8] = {
+    "result", "system", "sysutils", "tbytes", "tclass", "thrift", "tinterfacedobject", "tobject"
+  };
+
+  // reserved method names (lowercase!)
+  const std::string DELPHI_RESERVED_METHOD[31] = {
+    "afterconstruction", "beforedestruction", "classinfo", "classname", "classnameis", "classparent", 
+    "classtype", "cleanupinstance", "create", "defaulthandler", "destroy", "dispatch", "equals", 
+    "fieldaddress", "free", "freeinstance", "gethashcode", "getinterface", "getinterfaceentry", 
+    "getinterfacetable", "inheritsfrom", "initinstance", "instancesize", "methodaddress", "methodname", 
+    "newinstance", "read", "safecallexception", "tostring", "unitname", "write"
+  };
+
+  // reserved exception class method names (lowercase!)
+  const std::string DELPHI_RESERVED_METHOD_EXCEPTION[23] = {
+    "setinnerexception", "setstackinfo", "getstacktrace", "raisingexception", "createfmt", "createres", 
+    "createresfmt", "createhelp", "createfmthelp", "createreshelp", "createresfmthelp", "getbaseexception", 
+    "baseexception", "helpcontext", "innerexception", "message", "stacktrace", "stackinfo", 
+    "getexceptionstackinfoproc", "getstackinfostringproc", "cleanupstackinfoproc", "raiseouterexception", 
+    "throwouterexception"
+  };
+
+  // TODO: put all into one map, value=flags tells what it is
+  std::set<std::string> delphi_keywords                  = std::set<string>(DELPHI_KEYWORDS,                  DELPHI_KEYWORDS                  + sizeof(DELPHI_KEYWORDS)                  / sizeof(DELPHI_KEYWORDS[0]));
+  std::set<std::string> delphi_reserved_names            = std::set<string>(DELPHI_RESERVED_NAMES,            DELPHI_RESERVED_NAMES            + sizeof(DELPHI_RESERVED_NAMES)            / sizeof(DELPHI_RESERVED_NAMES[0]));
+  std::set<std::string> delphi_reserved_method           = std::set<string>(DELPHI_RESERVED_METHOD,           DELPHI_RESERVED_METHOD           + sizeof(DELPHI_RESERVED_METHOD)           / sizeof(DELPHI_RESERVED_METHOD[0]));
+  std::set<std::string> delphi_reserved_method_exception = std::set<string>(DELPHI_RESERVED_METHOD_EXCEPTION, DELPHI_RESERVED_METHOD_EXCEPTION + sizeof(DELPHI_RESERVED_METHOD_EXCEPTION) / sizeof(DELPHI_RESERVED_METHOD_EXCEPTION[0]));
+
+  bool find_keyword(std::set<std::string>& keywords, std::string name);
   std::string normalize_name(std::string name,
                              bool b_method = false,
                              bool b_exception_method = false,
                              bool b_force_underscore = false);
-  std::string empty_value(t_type* type);
+
   bool is_fully_defined_type(t_type* ttype);
   void add_defined_type(t_type* ttype);
   void init_known_types_list();
@@ -552,7 +592,7 @@
   }
 }
 
-bool t_delphi_generator::find_keyword(std::map<std::string, int>& keyword_map, std::string name) {
+bool t_delphi_generator::find_keyword(std::set<std::string>& keywords, std::string name) {
   std::string::size_type len = name.length();
 
   if (len <= 0) {
@@ -564,10 +604,11 @@
   if (nlast >= 1) {
     if (nlast == (len - 1)) {
       string new_name(name, 0, nlast);
-      return find_keyword(keyword_map, new_name);
+      return find_keyword(keywords, new_name);
     }
   }
-  return (keyword_map[name] == 1);
+
+  return (keywords.find(name) != keywords.end());
 }
 
 std::string t_delphi_generator::normalize_name(std::string name,
@@ -604,158 +645,6 @@
   }
 }
 
-void t_delphi_generator::create_keywords() {
-  delphi_keywords["and"] = 1;
-  delphi_keywords["end"] = 1;
-  delphi_keywords["interface"] = 1;
-  delphi_keywords["raise"] = 1;
-  delphi_keywords["uses"] = 1;
-  delphi_keywords["array"] = 1;
-  delphi_keywords["except"] = 1;
-  delphi_keywords["is"] = 1;
-  delphi_keywords["record"] = 1;
-  delphi_keywords["var"] = 1;
-  delphi_keywords["as"] = 1;
-  delphi_keywords["exports"] = 1;
-  delphi_keywords["label"] = 1;
-  delphi_keywords["repeat"] = 1;
-  delphi_keywords["while"] = 1;
-  delphi_keywords["asm"] = 1;
-  delphi_keywords["file"] = 1;
-  delphi_keywords["library"] = 1;
-  delphi_keywords["resourcestring"] = 1;
-  delphi_keywords["with"] = 1;
-  delphi_keywords["begin"] = 1;
-  delphi_keywords["finalization"] = 1;
-  delphi_keywords["mod"] = 1;
-  delphi_keywords["set"] = 1;
-  delphi_keywords["xor"] = 1;
-  delphi_keywords["case"] = 1;
-  delphi_keywords["finally"] = 1;
-  delphi_keywords["nil"] = 1;
-  delphi_keywords["shl"] = 1;
-  delphi_keywords["class"] = 1;
-  delphi_keywords["for"] = 1;
-  delphi_keywords["not"] = 1;
-  delphi_keywords["shr"] = 1;
-  delphi_keywords["const"] = 1;
-  delphi_keywords["function"] = 1;
-  delphi_keywords["object"] = 1;
-  delphi_keywords["string"] = 1;
-  delphi_keywords["constructor"] = 1;
-  delphi_keywords["goto"] = 1;
-  delphi_keywords["of"] = 1;
-  delphi_keywords["then"] = 1;
-  delphi_keywords["destructor"] = 1;
-  delphi_keywords["if"] = 1;
-  delphi_keywords["or"] = 1;
-  delphi_keywords["threadvar"] = 1;
-  delphi_keywords["dispinterface"] = 1;
-  delphi_keywords["implementation"] = 1;
-  delphi_keywords["out"] = 1;
-  delphi_keywords["to"] = 1;
-  delphi_keywords["div"] = 1;
-  delphi_keywords["in"] = 1;
-  delphi_keywords["packed"] = 1;
-  delphi_keywords["try"] = 1;
-  delphi_keywords["do"] = 1;
-  delphi_keywords["inherited"] = 1;
-  delphi_keywords["procedure"] = 1;
-  delphi_keywords["type"] = 1;
-  delphi_keywords["downto"] = 1;
-  delphi_keywords["initialization"] = 1;
-  delphi_keywords["program"] = 1;
-  delphi_keywords["unit"] = 1;
-  delphi_keywords["else"] = 1;
-  delphi_keywords["inline"] = 1;
-  delphi_keywords["property"] = 1;
-  delphi_keywords["until"] = 1;
-  delphi_keywords["private"] = 1;
-  delphi_keywords["protected"] = 1;
-  delphi_keywords["public"] = 1;
-  delphi_keywords["published"] = 1;
-  delphi_keywords["automated"] = 1;
-  delphi_keywords["at"] = 1;
-  delphi_keywords["on"] = 1;
-
-  // predefined types (lowercase!)
-  delphi_keywords["ansistring"] = 1;
-  delphi_keywords["string"] = 1;
-  delphi_keywords["boolean"] = 1;
-  delphi_keywords["shortint"] = 1;
-  delphi_keywords["smallint"] = 1;
-  delphi_keywords["integer"] = 1;
-  delphi_keywords["int64"] = 1;
-  delphi_keywords["double"] = 1;
-
-  // reserved variables and types (lowercase!)
-  delphi_reserved_names["result"] = 1;
-  delphi_reserved_names["system"] = 1;
-  delphi_reserved_names["sysutils"] = 1;
-  delphi_reserved_names["thrift"] = 1;
-  delphi_reserved_names["tbytes"] = 1;
-  delphi_reserved_names["tobject"] = 1;
-  delphi_reserved_names["tclass"] = 1;
-  delphi_reserved_names["tinterfacedobject"] = 1;
-
-  // reserved method names (lowercase!)
-  delphi_reserved_method["create"] = 1;
-  delphi_reserved_method["free"] = 1;
-  delphi_reserved_method["initinstance"] = 1;
-  delphi_reserved_method["cleanupinstance"] = 1;
-  delphi_reserved_method["classtype"] = 1;
-  delphi_reserved_method["classname"] = 1;
-  delphi_reserved_method["classnameis"] = 1;
-  delphi_reserved_method["classparent"] = 1;
-  delphi_reserved_method["classinfo"] = 1;
-  delphi_reserved_method["instancesize"] = 1;
-  delphi_reserved_method["inheritsfrom"] = 1;
-  delphi_reserved_method["methodaddress"] = 1;
-  delphi_reserved_method["methodname"] = 1;
-  delphi_reserved_method["fieldaddress"] = 1;
-  delphi_reserved_method["getinterface"] = 1;
-  delphi_reserved_method["getinterfaceentry"] = 1;
-  delphi_reserved_method["getinterfacetable"] = 1;
-  delphi_reserved_method["unitname"] = 1;
-  delphi_reserved_method["equals"] = 1;
-  delphi_reserved_method["gethashcode"] = 1;
-  delphi_reserved_method["tostring"] = 1;
-  delphi_reserved_method["safecallexception"] = 1;
-  delphi_reserved_method["afterconstruction"] = 1;
-  delphi_reserved_method["beforedestruction"] = 1;
-  delphi_reserved_method["dispatch"] = 1;
-  delphi_reserved_method["defaulthandler"] = 1;
-  delphi_reserved_method["newinstance"] = 1;
-  delphi_reserved_method["freeinstance"] = 1;
-  delphi_reserved_method["destroy"] = 1;
-  delphi_reserved_method["read"] = 1;
-  delphi_reserved_method["write"] = 1;
-
-  delphi_reserved_method_exception["setinnerexception"] = 1;
-  delphi_reserved_method_exception["setstackinfo"] = 1;
-  delphi_reserved_method_exception["getstacktrace"] = 1;
-  delphi_reserved_method_exception["raisingexception"] = 1;
-  delphi_reserved_method_exception["createfmt"] = 1;
-  delphi_reserved_method_exception["createres"] = 1;
-  delphi_reserved_method_exception["createresfmt"] = 1;
-  delphi_reserved_method_exception["createhelp"] = 1;
-  delphi_reserved_method_exception["createfmthelp"] = 1;
-  delphi_reserved_method_exception["createreshelp"] = 1;
-  delphi_reserved_method_exception["createresfmthelp"] = 1;
-  delphi_reserved_method_exception["getbaseexception"] = 1;
-  delphi_reserved_method_exception["baseexception"] = 1;
-  delphi_reserved_method_exception["helpcontext"] = 1;
-  delphi_reserved_method_exception["innerexception"] = 1;
-  delphi_reserved_method_exception["message"] = 1;
-  delphi_reserved_method_exception["stacktrace"] = 1;
-  delphi_reserved_method_exception["stackinfo"] = 1;
-  delphi_reserved_method_exception["getexceptionstackinfoproc"] = 1;
-  delphi_reserved_method_exception["getstackinfostringproc"] = 1;
-  delphi_reserved_method_exception["cleanupstackinfoproc"] = 1;
-  delphi_reserved_method_exception["raiseouterexception"] = 1;
-  delphi_reserved_method_exception["throwouterexception"] = 1;
-}
-
 void t_delphi_generator::add_delphi_uses_list(string unitname) {
   vector<std::string>::const_iterator s_iter;
   bool found = false;
@@ -776,7 +665,6 @@
   has_forward = false;
   has_enum = false;
   has_const = false;
-  create_keywords();
 
   add_delphi_uses_list("Classes");
   add_delphi_uses_list("SysUtils");
@@ -996,11 +884,11 @@
   }
 
   if (ttype->is_typedef()) {
-    return (1 == types_known[type_name(ttype)]);
+    return (types_known.find(type_name(ttype)) != types_known.end());
   }
 
   if (ttype->is_base_type()) {
-    return (1 == types_known[base_type_name((t_base_type*)ttype)]);
+    return (types_known.find(base_type_name((t_base_type*)ttype)) != types_known.end());
   } else if (ttype->is_enum()) {
     return true; // enums are written first, before all other types
   } else if (ttype->is_map()) {
@@ -1015,12 +903,12 @@
     return is_fully_defined_type(tlist->get_elem_type());
   }
 
-  return (1 == types_known[type_name(ttype)]);
+  return (types_known.find(type_name(ttype)) != types_known.end());
 }
 
 void t_delphi_generator::add_defined_type(t_type* ttype) {
   // mark as known type
-  types_known[type_name(ttype)] = 1;
+  types_known.insert(type_name(ttype));
 
   // check all pending typedefs
   std::list<t_typedef*>::iterator iter;
@@ -1044,15 +932,15 @@
 
 void t_delphi_generator::init_known_types_list() {
   // known base types
-  types_known[type_name(g_type_string)] = 1;
-  types_known[type_name(g_type_binary)] = 1;
-  types_known[type_name(g_type_uuid)] = 1;
-  types_known[type_name(g_type_bool)] = 1;
-  types_known[type_name(g_type_i8)] = 1;
-  types_known[type_name(g_type_i16)] = 1;
-  types_known[type_name(g_type_i32)] = 1;
-  types_known[type_name(g_type_i64)] = 1;
-  types_known[type_name(g_type_double)] = 1;
+  types_known.insert( type_name(g_type_string));
+  types_known.insert( type_name(g_type_binary));
+  types_known.insert( type_name(g_type_uuid));
+  types_known.insert( type_name(g_type_bool));
+  types_known.insert( type_name(g_type_i8));
+  types_known.insert( type_name(g_type_i16));
+  types_known.insert( type_name(g_type_i32));
+  types_known.insert( type_name(g_type_i64));
+  types_known.insert( type_name(g_type_double));
 }
 
 void t_delphi_generator::generate_enum(t_enum* tenum) {