-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor: Change C style casts to C++ style (Part 4) #11687
Conversation
✅ Deploy Preview for meta-velox canceled.
|
Test failures related to #11721 mostly. Will rebase after that PR is submit. |
ed180ee
to
01e404f
Compare
sumC_ += (double)count; | ||
sumCLogC_ += (double)count * std::log(count); | ||
sumC_ += static_cast<double>(count); | ||
sumCLogC_ += static_cast<double>(count * std::log(count)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be: static_cast<double>(count) * std::log(count);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch. Updated.
@@ -154,7 +154,7 @@ class ArrayWriterBenchmark : public functions::test::FunctionBenchmarkBase { | |||
} | |||
|
|||
vector_size_t size = 1'000; | |||
size_t totalItemsCount = (size) * (size + 1) / 2; | |||
size_t totalItemsCount = static_cast<size_t>((size) * (size + 1) / 2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess I have some questions around vector_size_t being int32_t
. A vector access via [] operator or at would use a size_type parameter which is an unsigned integral type.
And the Velox vectors should work similar to std::vector in terms of access.
If it was unsigned then we could use implicit type conversion which still would work here I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not 100% sure but I generally thought it was that way to keep the sizes of vectors bounded in Velox. But yes, being consistent with std::vector access is a good idea.
Maybe open a discussion in Velox about it ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I created #11816
As per the security guideline in https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es49-if-you-must-use-a-cast-use-a-named-cast Covers the findings in velox/functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, @aditi-pandit
@bikramSingh91 has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@bikramSingh91 merged this pull request in 109ef3b. |
…or#11687) Summary: As per the security guideline in https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es49-if-you-must-use-a-cast-use-a-named-cast Covers the findings in velox/functions Pull Request resolved: facebookincubator#11687 Reviewed By: Yuhta Differential Revision: D67060300 Pulled By: bikramSingh91 fbshipit-source-id: e127c7d36c3ef9248d2eb8fe0ae85d8f065871e6
As per the security guideline in
https://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#es49-if-you-must-use-a-cast-use-a-named-cast
Covers the findings in velox/functions