Here\'s a bit of code that is a considerable bottleneck after doing some measuring:
//-----------------------------------------------------------------------
If you really want fast, ditch istream and string and create a trivial class Read_Only_Text around const char*
& size
, then memory map the file and insert into unordered_set
with references to the embedded strings. It will mean you needlessly keep the 2mb file even though your number of unique keys may be much less, but it'll be very, very fast to populate. I know this is a pain, but I've done it several times for various tasks and the results are very good.