Commit a8b2b47c authored by Ben Kelly's avatar Ben Kelly Committed by Commit Bot

Blob: Reduce backing std::vector capacity when shrinking bytes.

As pointed out by mek@, currently BlobDataItem::ShrinkBytes only resizes
the number of elements in the backing std::vector.  The backing capacity
of the vector remains the same.  For any blob less than 512KB this will
result in wasted memory usage.

Bug: 1133110
Change-Id: I71de9ce6cf75afbc7029d86841c8e5a754b69b52
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2436868Reviewed-by: default avatarMarijn Kruisselbrink <mek@chromium.org>
Commit-Queue: Ben Kelly <wanderview@chromium.org>
Cr-Commit-Position: refs/heads/master@{#811834}
parent 55886f69
......@@ -193,6 +193,7 @@ void BlobDataItem::ShrinkBytes(size_t new_length) {
DCHECK_EQ(type_, Type::kBytes);
length_ = new_length;
bytes_.resize(length_);
bytes_.shrink_to_fit();
}
void BlobDataItem::PopulateFile(
......
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