C++ Logo

STD-DISCUSSION

Advanced search

Subject: Re: extremely long compile time with large number of string literals
From: Matthew Woehlke (mwoehlke.floss_at_[hidden])
Date: 2020-07-13 09:13:24


On 09/07/2020 19.11, Mandeep Sandhu via Std-Discussion wrote:
> On 09/07/2020 18.55, Ville Voutilainen wrote:
>> You can use an unordered_set with a custom comparator. That way
>> you can get the comparison to compare the data, not the pointers.
>
> Thanks, this sounds like a good workaround.

It may be worth noting that this may help your process startup time,
since you won't need to allocate string objects for all your values
(they'll just be pointers into your RODATA instead).

...you *might* get similar benefits from a collection of `const string`
instead of `string`, but I'm not sure to what extent `string` can be
constexpr, especially if you're stuck on C++11.

In either case, I wonder if we'll get to (or are already at?) the point
that the compiler can more-or-less build the set at compile time such
that the run-time construction cost is near-zero...

>> I'm not quite convinced this is on-topic any more. :) This is not a
>> "how to program correctly in C++" forum.
>
> I agree :) (an answer on quora led me to incorrectly assume that this
> was a list for discussing C++ stdlib related questions (since my
> problem stemmed from a class i stdlib), whereas this list is more for
> discussion around the C++ standard as such?)

The standard library is part of the standard. Whether or not an
algorithm is permitted to exhibit certain performance characteristics
would, I believe, be on topic. IOW, the original message was tenuously
on topic, but we've definitely drifted off :-). Note that Ville is not
"convinced this is on-topic *any more*" (emphasis added).

-- 
Matthew

STD-DISCUSSION list run by std-discussion-owner@lists.isocpp.org

Older Archives on Google Groups