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

Unified Diff: net/quic/quic_utils.h

Issue 140253014: QUIC - Moved FindOrNull and FindOrDie to a separate files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Used similarity to upload Created 6 years, 11 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/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_utils_chromium.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/quic/quic_utils.h
diff --git a/net/quic/quic_utils.h b/net/quic/quic_utils.h
index 7357dfe92a86589ec39cad0d7351227b263e8fa0..05d88ca61dd2b7d5489d832173d29e49433071b1 100644
--- a/net/quic/quic_utils.h
+++ b/net/quic/quic_utils.h
@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
-// Some helpers for quic
+// Some helpers for quic.
#ifndef NET_QUIC_QUIC_UTILS_H_
#define NET_QUIC_QUIC_UTILS_H_
@@ -13,69 +13,6 @@
namespace net {
-//
-// Find*()
-//
-
-// Returns a const reference to the value associated with the given key if it
-// exists. Crashes otherwise.
-//
-// This is intended as a replacement for operator[] as an rvalue (for reading)
-// when the key is guaranteed to exist.
-//
-// operator[] for lookup is discouraged for several reasons:
-// * It has a side-effect of inserting missing keys
-// * It is not thread-safe (even when it is not inserting, it can still
-// choose to resize the underlying storage)
-// * It invalidates iterators (when it chooses to resize)
-// * It default constructs a value object even if it doesn't need to
-//
-// This version assumes the key is printable, and includes it in the fatal log
-// message.
-template <class Collection>
-const typename Collection::value_type::second_type&
-FindOrDie(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- CHECK(it != collection.end()) << "Map key not found: " << key;
- return it->second;
-}
-
-// Same as above, but returns a non-const reference.
-template <class Collection>
-typename Collection::value_type::second_type&
-FindOrDie(Collection& collection, // NOLINT
- const typename Collection::value_type::first_type& key) {
- typename Collection::iterator it = collection.find(key);
- CHECK(it != collection.end()) << "Map key not found: " << key;
- return it->second;
-}
-
-// Returns a pointer to the const value associated with the given key if it
-// exists, or NULL otherwise.
-template <class Collection>
-const typename Collection::value_type::second_type*
-FindOrNull(const Collection& collection,
- const typename Collection::value_type::first_type& key) {
- typename Collection::const_iterator it = collection.find(key);
- if (it == collection.end()) {
- return 0;
- }
- return &it->second;
-}
-
-// Same as above but returns a pointer to the non-const value.
-template <class Collection>
-typename Collection::value_type::second_type*
-FindOrNull(Collection& collection, // NOLINT
- const typename Collection::value_type::first_type& key) {
- typename Collection::iterator it = collection.find(key);
- if (it == collection.end()) {
- return 0;
- }
- return &it->second;
-}
-
class NET_EXPORT_PRIVATE QuicUtils {
public:
enum Priority {
@@ -83,7 +20,7 @@ class NET_EXPORT_PRIVATE QuicUtils {
PEER_PRIORITY,
};
- // returns the 64 bit FNV1a hash of the data. See
+ // Returns the 64 bit FNV1a hash of the data. See
// http://www.isthe.com/chongo/tech/comp/fnv/index.html#FNV-param
static uint64 FNV1a_64_Hash(const char* data, int len);
« no previous file with comments | « net/quic/quic_sent_packet_manager.cc ('k') | net/quic/quic_utils_chromium.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698