This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [RFC] move COW basic_string and SSO basic_string to separate files
- From: Thomas Rodgers <trodgers at redhat dot com>
- To: Ville Voutilainen <ville dot voutilainen at gmail dot com>
- Cc: Daniel Krügler <daniel dot kruegler at gmail dot com>, Jonathan Wakely <jwakely at redhat dot com>, libstdc++ <libstdc++ at gcc dot gnu dot org>
- Date: Wed, 12 Dec 2018 16:26:08 -0800
- Subject: Re: [RFC] move COW basic_string and SSO basic_string to separate files
- References: <20181211143104.GA27131@redhat.com> <CAGNvRgCix8o8hvPSVkm98fi7-cHufnB-fcA_iKnEZ0q3WSBYLA@mail.gmail.com> <CAFk2RUaV77g8XU=zk5HBCDnPeYP6y0RR=kbwk6OUvzABoFj-xA@mail.gmail.com>
> Strongly in favor of a file split; the separate files become much less
> macro-infested.
+1
Ville Voutilainen writes:
> On Tue, 11 Dec 2018 at 18:15, Daniel Krügler <daniel.kruegler@gmail.com> wrote:
>>
>> Am Di., 11. Dez. 2018 um 15:31 Uhr schrieb Jonathan Wakely <jwakely@redhat.com>:
>> >
>> > Often when I'm poking around in <bits/basic_string.h> and/or
>> > <bits/basic_string.tcc> I lose context and am not sure if I'm looking
>> > at a member of the old string type or the new one. I've considered
>> > putting comments above each member definition in the .tcc file saying
>> > "COW" or "SSO" but asimpler solution might be to move the definitions
>> > to separate files.
>> >
>> > This has the additional advantage of only having to parse the one
>> > we're actually using in a given translation unit:
>> >
>> > #if _GLIBCXX_USE_CXX11_ABI
>> > # include <bits/sso_string.h>
>> > #else
>> > # include <bits/cow_string.h>
>> > #endif
>> >
>> > That's approx. 3500 fewer lines to preprocess per compilation.
>> >
>> > Are there advantages to having them both in one place? For example,
>> > when fixing a bug, is it helpful to be able to find all occurrences of
>> > a name in a single file, across both COW and SSO types? Since the
>> > members are already spread across the .h and .tcc files, I think that
>> > ship already sailed.
>>
>> I appreciate your suggested refactoring. As you say, assuming that
>> searching in the same file would be sufficient to perform a fix in
>> both places is an illusion. IMO it is much easier to work with the new
>> code structure in two separate files.
>
> Strongly in favor of a file split; the separate files become much less
> macro-infested.