C++ Logo


Advanced search

Re: extremely long compile time with large number of string literals

From: Mandeep Sandhu <mandeepsandhu.chd_at_[hidden]>
Date: Mon, 13 Jul 2020 09:52:18 -0700
> ...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.

I don't know. I guess its best to benchmark and see how much
performance difference I'd get.

> 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 wonder if const string objects can point to string literals kept in
the .rodata section without having the need to allocate for it at
runtime (or do they already do something similar currently?).
> >> 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).

Well, I wasn't sure if the performance issue with the way
initializer_lists work with large numbers of non-trivial types is a
compiler issue or a language one! :)
(I posted it on the gcc-help ML and someone confirmed that it is
indeed an issue with the gcc generates code for initializer_list,
causing the build time to be roughly quadratic in the number of list

Thanks for your input!

> --
> Matthew

Received on 2020-07-13 11:55:45