-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Replace memset with constexpr fill_n in bigint::align and fix memset count to account for sizeof T #4471
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
Replace memset with constexpr fill_n in bigint::align and fix memset count to account for sizeof T #4471
Changes from 3 commits
5ffa586
90a59f5
d174022
7a9392b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -553,6 +553,7 @@ FMT_CONSTEXPR auto fill_n(OutputIt out, Size count, const T& value) | |
| template <typename T, typename Size> | ||
| FMT_CONSTEXPR20 auto fill_n(T* out, Size count, char value) -> T* { | ||
| if (is_constant_evaluated()) return fill_n<T*, Size, T>(out, count, value); | ||
| static_assert(1 == sizeof(T), "sizeof(T) must be 1 to use char for initialization"); | ||
| std::memset(out, value, to_unsigned(count)); | ||
| return out + count; | ||
| } | ||
|
|
@@ -2799,7 +2800,7 @@ class bigint { | |
| bigits_.resize(to_unsigned(num_bigits + exp_difference)); | ||
| for (int i = num_bigits - 1, j = i + exp_difference; i >= 0; --i, --j) | ||
| bigits_[j] = bigits_[i]; | ||
| memset(bigits_.data(), 0, to_unsigned(exp_difference) * sizeof(bigit)); | ||
| fill_n(bigits_.data(), to_unsigned(exp_difference), 0U); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. bigit is a uint32_t so bigits_.data() returns a uint32_t*. 0U is the unsigned literal for 0. I could use |
||
| exp_ -= exp_difference; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.