Change RedisConnection::Query::value_type from String to std::variant<const char*,String>#10391
Open
Change RedisConnection::Query::value_type from String to std::variant<const char*,String>#10391
Conversation
Member
Author
|
Strange, it worked on my machine... |
Member
|
The idea looks fine in general. Besides getting it to work, you might want to take a look at |
Member
Author
|
Like, |
Member
|
Probably something like that. A function for it might work too, but a small class could be nicer overall. |
ab1d887 to
7a5d6f3
Compare
yhabteab
reviewed
Apr 2, 2025
050665e to
cfc5532
Compare
cfc5532 to
12e8c73
Compare
It was copied anyway.
to ease changing that type in the future.
…d::vector) This expresses what kind of vector it is and allows to easily change those types in the future.
Especially our history messages contain lots of hardcoded C string literals "like this one". At runtime, they get translated to pointers to constant global memory, const char*. String malloc(3)s and copies these data every time. In contrast, the new type just stores the address if any. (Actually, const char* is wrapped by std::string_view to not compute its length every time.)
Member
Author
|
Fine, @yhabteab, you have won... |
12e8c73 to
d8a0d08
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
(Find TL;DR below)
Seriously speaking, 70ca88a pollutes the diff and should be viewed on its own. It just replaces
std::vector<String>with RedisConnection::Query. As RedisConnection::Query already was astd::vector<String>, this is a no-op on its own. But it allows to just change RedisConnection::Query itself and affect all its usages at once.Why do we have to change String to std::variant<const char*,String> at all? (efe5f22)
Especially our history messages contain lots of hardcoded C string literals "like this one". At runtime, they get translated to pointers to constant global memory, const char*. String malloc(3)s and copies these data every time. In contrast, std::variant<const char*,String> just stores the address if any.
TL;DR
std::vector<T>fixes #10276
ref/NC/820479