Make interfaces use string_views more consistently#946
Make interfaces use string_views more consistently#946tmadlener merged 17 commits intoAIDASoft:masterfrom
Conversation
|
I have gone over things again and now there are only two maps left that actually have to have transparent In some cases the map still acts as owner of the initial string. For those cases we keep either the map with the transparent lookup or we internally construct a @wdconinc our framework integration takes these changes transparently, which is what I would expect, but I can't as trivially test EICrecon with it. If you have an easy / quick way of doing that, I would appreciate any feedback about breakages. |
4bfc19b to
e68f3ec
Compare
e68f3ec to
421472e
Compare
I'll give it a shot. Busy day today but hope to have a chance in between meetings. |
|
Thanks and no worries. I still have to figure out why this makes some of the CI fail in code that hasn't been (obviously) changed. |
Initial changes via Claude
Refactor things slightly to remove spurious double lookups and make sure all methods take string_views
The keys that are used with the map live in the m_availableCategories member.
|
Looks like failure is coming from: std::string_view(subrange.begin(), subrange.end()) std::views::split doesn’t provide contiguous iterators, so this isn’t a valid string_view construction (GCC 11 catches it) |
|
The problem is that there are explicit guards to make this work with gcc11 in the code. And that code is not touched by this PR at all (it's not even called by code that is touched by this PR). So the question is why is a CI run ending up in a code section from which it should be guarded in the first place now when it hasn't before and nothing should have changed. |
|
Ah got it..then maybe something in this PR is changing which code paths get instantiated even if not directly touched. Could it be affecting overload resolution or template instantiation so that guarded code is now being selected in gcc11? |
This comes via root cling, so clang is defined, so it pulls in this code? |
|
Good catch. I think then I know why. This PR makes Sigh, time to split that header then, I guess. Unless someone wants to figure out the correct pre-processor chain of |
|
Happy to take a shot at the preprocessor path if useful Splitting MiscHelpers.h is good hygiene on top but secondary to fixing the construction itself I think so |
The pre-processor checks in splitString do not catch cling and older versions of ROOT end up in a branch that doesn't compile.
449e9a6 to
71b05b3
Compare
|
Splitting things off into a different header does the trick it seems. From my side this is ready and I would merge soon(ish), unless someone still wants more time for testing. |
| /// | ||
| /// @param name The name of the datamodel | ||
| const std::string_view getDatamodelDefinition(const std::string& name) const; | ||
| const std::string_view getDatamodelDefinition(std::string_view name) const; |
There was a problem hiding this comment.
| const std::string_view getDatamodelDefinition(std::string_view name) const; | |
| const std::string_view getDatamodelDefinition(const std::string_view name) const; |
Is passing with const the best practice? I like to have const wherever it can be.
There was a problem hiding this comment.
I haven't really seen it with const in practice (but maybe I have just looked in the wrong places). The underlying const char* is immutable in any case, so something like
const std::string_view getDatamodelDefinition(std::string_view name) {
name[0] = 'a';
}doesn't even compile.
You could do
name = "abcd";but those changes will not be visible outside (i.e. string_view doesn't behave like a span<char>).
I don't have a strong opinion here, but the convention seems to be without const.
Co-authored-by: Juan Miguel Carceller <22276694+jmcarcell@users.noreply.github.com>
|
Merging this tomorrow, unless there are more comments. |
BEGINRELEASENOTES
std::string_viewarguments instead ofconst std::string&for categories, etc. to be more overall more consistent and to avoid having to dostring_viewtostringconversions on the user side (see also #945).ENDRELEASENOTES
This is a largely claude generated rework of current interfaces to fix the points raised in #945. I did some cleanup, but I will have to do another round to see where it actually makes sense to accept a
string_viewand where we were more consistent with taking astd::string.