From a70aac6a11c4f9ccf417870b538ba50764556ca7 Mon Sep 17 00:00:00 2001 From: Doug Thayer Date: Wed, 9 Aug 2017 10:21:09 -0700 Subject: [PATCH] Bug 1388748 - Don't resize histogram ranges on init r=gfritzsche We were using std::vector::assign, which resizes the vector to match the incoming data. This isn't what we want, as ranges_ has already been sized to bucket_count_ + 1. Instead, just use a copy. MozReview-Commit-ID: EGuW5jj7Rpq --HG-- extra : rebase_source : 616d61fc27c7e43c22ea69e11e070ba958bf20a9 --- ipc/chromium/src/base/histogram.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ipc/chromium/src/base/histogram.cc b/ipc/chromium/src/base/histogram.cc index c8d0132fbe7f..97af3e5c90e7 100644 --- a/ipc/chromium/src/base/histogram.cc +++ b/ipc/chromium/src/base/histogram.cc @@ -273,7 +273,8 @@ Histogram::~Histogram() { } void Histogram::InitializeBucketRangeFromData(const int* buckets) { - ranges_.assign(buckets, buckets + bucket_count()); + DCHECK_EQ(bucket_count_ + 1, ranges_.size()); + std::copy_n(buckets, bucket_count_, ranges_.data()); ResetRangeChecksum(); DCHECK(ValidateBucketRanges()); }