title: Efficient memory storage and retrieval of categorized string literals in C++
body: <p>Note: This is a follow up to <a href="https://stackoverflow.com/questions/3738092/c-string-literal-storage-between-multiple-copies-of-process-or-library">this question</a>.</p>
  
  <p>I have a "legacy" program which does hundreds of string matches against big chunks of HTML. For example if the HTML matches 1 of 20+ strings, do something. If it matches 1 of 4 other strings, do something else. There are 50-100 groups of these strings to match against these chunks of HTML (usually whole pages).</p>
  
  <p>I'm taking a whack at refactoring this mess of code and trying to come up with a good approach to do all these matches.</p>
  
  <p>The performance requirements of this code are rather strict. It needs to not wait on I/O when doing these matches so they need to be in memory. Also there can be 100+ copies of this process running at the same time so large I/O on startup could cause slow I/O for other copies.</p>
  
  <p>With these requirements in mind it would be most efficient if only one copy of these strings are stored in RAM (see my previous question linked above).</p>
  
  <p>This program currently runs on Windows with Microsoft compiler but I'd like to keep the solution as cross-platform as possible so I don't think I want to use PE resource files or something.</p>
  
  <p>Mmapping an external file might work but then I have the issue of keeping program version and data version in sync, one does not normally change without the other. Also this requires some file "format" which adds a layer of complexity I'd rather not have.</p>
  
  <p>So after all of this pre-amble it seems like the best solution is to have a bunch arrays of strings which I can then iterate over. This seems kind of messy as I'm mixing code and data heavily, but with the above requirements is there any better way to handle this sort of situation?</p>