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

Side by Side Diff: net/spdy/hpack/hpack_header_table_test.cc

Issue 1354773002: Avoid string construction overhead for lookup-only HpackEntry objects. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit: return feels weird in a constructor. Created 5 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
« no previous file with comments | « net/spdy/hpack/hpack_entry.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "net/spdy/hpack/hpack_header_table.h" 5 #include "net/spdy/hpack/hpack_header_table.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 protected: 72 protected:
73 typedef std::vector<HpackEntry> HpackEntryVector; 73 typedef std::vector<HpackEntry> HpackEntryVector;
74 74
75 HpackHeaderTableTest() : table_(), peer_(&table_) {} 75 HpackHeaderTableTest() : table_(), peer_(&table_) {}
76 76
77 // Returns an entry whose Size() is equal to the given one. 77 // Returns an entry whose Size() is equal to the given one.
78 static HpackEntry MakeEntryOfSize(uint32 size) { 78 static HpackEntry MakeEntryOfSize(uint32 size) {
79 EXPECT_GE(size, HpackEntry::kSizeOverhead); 79 EXPECT_GE(size, HpackEntry::kSizeOverhead);
80 string name((size - HpackEntry::kSizeOverhead) / 2, 'n'); 80 string name((size - HpackEntry::kSizeOverhead) / 2, 'n');
81 string value(size - HpackEntry::kSizeOverhead - name.size(), 'v'); 81 string value(size - HpackEntry::kSizeOverhead - name.size(), 'v');
82 HpackEntry entry(name, value); 82 HpackEntry entry(name, value, false, 0);
83 EXPECT_EQ(size, entry.Size()); 83 EXPECT_EQ(size, entry.Size());
84 return entry; 84 return entry;
85 } 85 }
86 86
87 // Returns a vector of entries whose total size is equal to the given 87 // Returns a vector of entries whose total size is equal to the given
88 // one. 88 // one.
89 static HpackEntryVector MakeEntriesOfTotalSize(uint32 total_size) { 89 static HpackEntryVector MakeEntriesOfTotalSize(uint32 total_size) {
90 EXPECT_GE(total_size, HpackEntry::kSizeOverhead); 90 EXPECT_GE(total_size, HpackEntry::kSizeOverhead);
91 uint32 entry_size = HpackEntry::kSizeOverhead; 91 uint32 entry_size = HpackEntry::kSizeOverhead;
92 uint32 remaining_size = total_size; 92 uint32 remaining_size = total_size;
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 HpackEntry entry2(DynamicEntry("name", "value")); 435 HpackEntry entry2(DynamicEntry("name", "value"));
436 436
437 HpackHeaderTable::EntryComparator comparator; 437 HpackHeaderTable::EntryComparator comparator;
438 EXPECT_FALSE(comparator(&entry1, &entry1)); 438 EXPECT_FALSE(comparator(&entry1, &entry1));
439 EXPECT_FALSE(comparator(&entry2, &entry2)); 439 EXPECT_FALSE(comparator(&entry2, &entry2));
440 } 440 }
441 441
442 } // namespace 442 } // namespace
443 443
444 } // namespace net 444 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/hpack/hpack_entry.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698