Commit 4ffaea74 by Copybara-Service

Merge pull request #1416 from AtariDreams:fill

PiperOrigin-RevId: 526675031
Change-Id: Ib84423ccea2d0183166194a0916a97a7ed32915c
parents 0b49f8af a26fc02d
...@@ -361,7 +361,7 @@ void CountingSort(T* values, size_t num_values) { ...@@ -361,7 +361,7 @@ void CountingSort(T* values, size_t num_values) {
// Write that many copies of each unique value to the array. // Write that many copies of each unique value to the array.
T* ABSL_RANDOM_INTERNAL_RESTRICT p = values; T* ABSL_RANDOM_INTERNAL_RESTRICT p = values;
for (const auto& value_count : unique) { for (const auto& value_count : unique) {
std::fill(p, p + value_count.second, value_count.first); std::fill_n(p, value_count.second, value_count.first);
p += value_count.second; p += value_count.second;
} }
ABSL_RAW_CHECK(p == values + num_values, "Did not produce enough output"); ABSL_RAW_CHECK(p == values + num_values, "Did not produce enough output");
......
...@@ -296,10 +296,8 @@ template <int max_words> ...@@ -296,10 +296,8 @@ template <int max_words>
std::min(n / kLargePowerOfFiveStep, kLargestPowerOfFiveIndex); std::min(n / kLargePowerOfFiveStep, kLargestPowerOfFiveIndex);
if (first_pass) { if (first_pass) {
// just copy, rather than multiplying by 1 // just copy, rather than multiplying by 1
std::copy( std::copy_n(LargePowerOfFiveData(big_power),
LargePowerOfFiveData(big_power), LargePowerOfFiveSize(big_power), answer.words_);
LargePowerOfFiveData(big_power) + LargePowerOfFiveSize(big_power),
answer.words_);
answer.size_ = LargePowerOfFiveSize(big_power); answer.size_ = LargePowerOfFiveSize(big_power);
first_pass = false; first_pass = false;
} else { } else {
......
...@@ -121,7 +121,7 @@ class BigUnsigned { ...@@ -121,7 +121,7 @@ class BigUnsigned {
++size_; ++size_;
} }
} }
std::fill(words_, words_ + word_shift, 0u); std::fill_n(words_, word_shift, 0u);
} }
} }
...@@ -197,7 +197,7 @@ class BigUnsigned { ...@@ -197,7 +197,7 @@ class BigUnsigned {
} }
void SetToZero() { void SetToZero() {
std::fill(words_, words_ + size_, 0u); std::fill_n(words_, size_, 0u);
size_ = 0; size_ = 0;
} }
......
...@@ -114,7 +114,7 @@ class Vec { ...@@ -114,7 +114,7 @@ class Vec {
if (src->ptr_ == src->space_) { if (src->ptr_ == src->space_) {
// Need to actually copy // Need to actually copy
resize(src->size_); resize(src->size_);
std::copy(src->ptr_, src->ptr_ + src->size_, ptr_); std::copy_n(src->ptr_, src->size_, ptr_);
src->size_ = 0; src->size_ = 0;
} else { } else {
Discard(); Discard();
...@@ -148,7 +148,7 @@ class Vec { ...@@ -148,7 +148,7 @@ class Vec {
size_t request = static_cast<size_t>(capacity_) * sizeof(T); size_t request = static_cast<size_t>(capacity_) * sizeof(T);
T* copy = static_cast<T*>( T* copy = static_cast<T*>(
base_internal::LowLevelAlloc::AllocWithArena(request, arena)); base_internal::LowLevelAlloc::AllocWithArena(request, arena));
std::copy(ptr_, ptr_ + size_, copy); std::copy_n(ptr_, size_, copy);
Discard(); Discard();
ptr_ = copy; ptr_ = copy;
} }
......
...@@ -105,7 +105,7 @@ std::string FixedOffsetToName(const seconds& offset) { ...@@ -105,7 +105,7 @@ std::string FixedOffsetToName(const seconds& offset) {
offset_minutes %= 60; offset_minutes %= 60;
const std::size_t prefix_len = sizeof(kFixedZonePrefix) - 1; const std::size_t prefix_len = sizeof(kFixedZonePrefix) - 1;
char buf[prefix_len + sizeof("-24:00:00")]; char buf[prefix_len + sizeof("-24:00:00")];
char* ep = std::copy(kFixedZonePrefix, kFixedZonePrefix + prefix_len, buf); char* ep = std::copy_n(kFixedZonePrefix, prefix_len, buf);
*ep++ = sign; *ep++ = sign;
ep = Format02d(ep, offset_hours); ep = Format02d(ep, offset_hours);
*ep++ = ':'; *ep++ = ':';
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment