Large map<srting,string> Initialization

Tom Browder tbrowder@cox.net
Sun May 22 12:39:00 GMT 2005


I need a map with many string pairs and I instantiate it like this:

  map<const string,const string> mymap;
  mymap.insert(make_pair("long_string1", "long_string_val1"));
  ...
  mymap.insert(make_pair("long_string10000", "long_string_val10000"));

The strings generally are about 30-40 characters in length.

The source file is very long and g++ (4.0) takes a very long time (and a
large amount of memory) to compile it.

I have broken the file into smaller pieces (which helps with memory usage)
but the total compile time is about the same.

Note that the map is never modified after the initial load, it is merely
used for looking up the values.

Several questions:

1.  Is there a better way to initialize such a map?

2.  Are there g++ options that would help?

3.  Are there linker/loader tricks that would help?

Thanks.

Tom Browder



More information about the Gcc-help mailing list