From a26fc02d1ea9a2f0770c1297db0a049b9dd4b941 Mon Sep 17 00:00:00 2001 From: Rose <83477269+AtariDreams@users.noreply.github.com> Date: Thu, 16 Mar 2023 17:32:09 -0400 Subject: Prefer copy_n and fill_n over copy and fill where appropriate. This lets us avoid having to do the addition manually. --- absl/synchronization/internal/graphcycles.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'absl/synchronization') diff --git a/absl/synchronization/internal/graphcycles.cc b/absl/synchronization/internal/graphcycles.cc index feec4581..01489544 100644 --- a/absl/synchronization/internal/graphcycles.cc +++ b/absl/synchronization/internal/graphcycles.cc @@ -114,7 +114,7 @@ class Vec { if (src->ptr_ == src->space_) { // Need to actually copy resize(src->size_); - std::copy(src->ptr_, src->ptr_ + src->size_, ptr_); + std::copy_n(src->ptr_, src->size_, ptr_); src->size_ = 0; } else { Discard(); @@ -148,7 +148,7 @@ class Vec { size_t request = static_cast(capacity_) * sizeof(T); T* copy = static_cast( base_internal::LowLevelAlloc::AllocWithArena(request, arena)); - std::copy(ptr_, ptr_ + size_, copy); + std::copy_n(ptr_, size_, copy); Discard(); ptr_ = copy; } -- cgit v1.2.3