IcingaDB: consistently use const char* literals everywhere#10744
IcingaDB: consistently use const char* literals everywhere#10744
const char* literals everywhere#10744Conversation
|
Re-added the checksum support to the |
ad94743 to
7a1ce8d
Compare
7a1ce8d to
44fd2a0
Compare
44fd2a0 to
e103209
Compare
57fa8bd to
45af026
Compare
|
Addressed all open requested changes now! |
|
Apparently, not all boost versions we support provide |
Is available since 1.78 only.
|
45af026 to
73a892f
Compare
Changed to |
|
Fixed one bug 🙈! |
jschmidt-icinga
left a comment
There was a problem hiding this comment.
Other than the following I think this looks good now.
Shame about boost::span, but it should be fine since the copy doesn't happen often and hopefully we'll be able to move to std::span soon.
f4b8620 to
b257083
Compare
fd588d8 to
09d5ed0
Compare
|
#10744 (review) was just the result of a quick look over the new code if I quickly spot something that can be improved. That has been addressed though I didn't do a full review. @jschmidt-icinga As you've reviewed the full PR before, can you please take another look at it? If you're happy with the latest changes as well, then it's fine for me. |
Co-Authored-By: Julian Brost <julian.brost@icinga.com>
09d5ed0 to
2fbf083
Compare
|
Rebased to make use of #10756, so I can pass |
2fbf083 to
fa514e6
Compare
|
Just inlined the now superfluous |
jschmidt-icinga
left a comment
There was a problem hiding this comment.
I gave this another quick look and I think it's fine. There are no functional changes except what we talked about in GetTypeOverwriteKeys() and what was previously GetTypeDumpSignalKeys() and the rest is a straight forward refactoring to use the string literals instead of runtime strings.
There is a little remaining worry about using the linear-time lookups in actually hot code, but I think it's at least not going to be slower than if/else comparisons to the const Type::Ptr& and probably not slower than the std::unordered_set of the actual Type::Ptr, which doesn't have the additional dereference, but adds the hash function (and the set's binary search probably isn't faster than linear search at these small data-sizes either). It would have been nice if the lookup could've been constant time, but there's no way to do that with the way our reflection types work currently.
@julianbrost can this now be merged or do you want to have a final quick look at it again? Otherwise, please merge it! Ty. |
Previously, we used a
m_PrefixConfigObjectandm_PrefixConfigCheckSummember variables to store the Redis key prefixes for configuration objects and their checksums. So, every time we needed to use these prefixes, we used such constructs asm_PrefixConfigObject + "some:suffix"to create the full Redis key. As a result, we give up the opportunity to just useconst char*literals as the resulted Redis keys, since we always convert them to ourStringtype unconditionally. However, after #10391 has been merged, we can now useconst char*literals consistently everywhere, unless it's absolutely necessary to useStringobjects. Yesterday, @julianbrost had a genial idea how we can get rid of them_PrefixConfigObjectandm_PrefixConfigCheckSummember variables and just useconst char*literals everywhere, while still keeping similar code readability and maintainability. The idea is to make these prefixes a macro, so that we can use such constructs asCONFIG_REDIS_KEY_PREFIX "host:state"to create the full Redis key, and the macro will expand to the appropriateconst char*literal. This PR implements this idea, and I tried my best to reduce the number of places where we need to useStringobjects to the absolute minimum. You might think that it would be better to store theconst char*literals somewhere in a variable now, but I think it's not necessary, as the compiler will optimize the code and deduplicate all the string literals anyway, so we won't have any performance issues apart from being duplicated in the source code.Just to test, that the compiler/linker does indeed deduplicate the string literals, you can run the following command and grep for whatever string literal you want to check and it should be present only once in the output:
ref #10619