[RFC] move COW basic_string and SSO basic_string to separate files
Daniel Krügler
daniel.kruegler@gmail.com
Tue Dec 11 16:15:00 GMT 2018
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.
- Daniel
More information about the Libstdc++
mailing list