Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8)

Side by Side Diff: third_party/WebKit/Source/core/fetch/CachedMetadata.cpp

Issue 2258743002: Reserve Vector's capacity manually in CachedMetadata (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/fetch/CachedMetadata.h"
6
7 namespace blink {
8
9 CachedMetadata::CachedMetadata(const char* data, size_t size)
10 {
11 // We need to define a local variable to use the constant in DCHECK.
12 constexpr auto kDataStart = CachedMetadata::kDataStart;
13 // Serialized metadata should have non-empty data.
14 DCHECK_GT(size, kDataStart);
esprehn 2016/08/26 04:51:01 DCHECK(data)
yhirano 2016/08/26 08:50:54 Done.
15 m_serializedData.reserveCapacity(size);
esprehn 2016/08/26 04:51:01 reserveInitialCapacity
yhirano 2016/08/26 08:50:54 Done.
16 m_serializedData.append(data, size);
17 }
18
19 CachedMetadata::CachedMetadata(uint32_t dataTypeID, const char* data, size_t siz e)
20 {
21 // Don't allow an ID of 0, it is used internally to indicate errors.
22 DCHECK(dataTypeID);
23 DCHECK(data);
24
25 m_serializedData.reserveCapacity(sizeof(uint32_t) + size);
esprehn 2016/08/26 04:51:01 reserveInitialCapacity.
yhirano 2016/08/26 08:50:54 Done.
26 m_serializedData.append(reinterpret_cast<const char*>(&dataTypeID), sizeof(u int32_t));
27 m_serializedData.append(data, size);
28 }
29
30 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/fetch/CachedMetadata.h ('k') | third_party/WebKit/Source/core/fetch/CachedMetadataHandler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698