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

Unified Diff: net/spdy/hpack/hpack_entry.h

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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « net/spdy/hpack/hpack_encoder_test.cc ('k') | net/spdy/hpack/hpack_entry.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/spdy/hpack/hpack_entry.h
diff --git a/net/spdy/hpack/hpack_entry.h b/net/spdy/hpack/hpack_entry.h
index 887b515aa0618034deb84ddb12bcb7123f4c132b..d3d2c618d095a49bdc3f0e7ecf8958f9f38f7cb9 100644
--- a/net/spdy/hpack/hpack_entry.h
+++ b/net/spdy/hpack/hpack_entry.h
@@ -5,8 +5,6 @@
#ifndef NET_SPDY_HPACK_ENTRY_H_
#define NET_SPDY_HPACK_ENTRY_H_
-#include <cstddef>
-#include <set>
#include <string>
#include "base/basictypes.h"
@@ -35,6 +33,7 @@ class NET_EXPORT_PRIVATE HpackEntry {
//
// The combination of |is_static| and |insertion_index| allows an
// HpackEntryTable to determine the index of an HpackEntry in O(1) time.
+ // Copies |name| and |value|.
HpackEntry(base::StringPiece name,
base::StringPiece value,
bool is_static,
@@ -42,16 +41,20 @@ class NET_EXPORT_PRIVATE HpackEntry {
// Create a 'lookup' entry (only) suitable for querying a HpackEntrySet. The
// instance InsertionIndex() always returns 0 and IsLookup() returns true.
+ // The memory backing |name| and |value| must outlive this object.
HpackEntry(base::StringPiece name, base::StringPiece value);
+ HpackEntry(const HpackEntry& other);
+ HpackEntry& operator=(const HpackEntry& other);
+
// Creates an entry with empty name and value. Only defined so that
// entries can be stored in STL containers.
HpackEntry();
~HpackEntry();
- const std::string& name() const { return name_; }
- const std::string& value() const { return value_; }
+ base::StringPiece name() const { return name_ref_; }
+ base::StringPiece value() const { return value_ref_; }
// Returns whether this entry is a member of the static (as opposed to
// dynamic) table.
@@ -76,10 +79,15 @@ class NET_EXPORT_PRIVATE HpackEntry {
STATIC,
};
- // TODO(jgraettinger): Reduce copies, possibly via SpdyPinnableBufferPiece.
+ // These members are not used for LOOKUP entries.
std::string name_;
std::string value_;
+ // These members are always valid. For DYNAMIC and STATIC entries, they
+ // always point to |name_| and |value_|.
+ base::StringPiece name_ref_;
+ base::StringPiece value_ref_;
+
// The entry's index in the total set of entries ever inserted into the header
// table.
size_t insertion_index_;
« no previous file with comments | « net/spdy/hpack/hpack_encoder_test.cc ('k') | net/spdy/hpack/hpack_entry.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698