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

Unified Diff: net/base/priority_queue.h

Issue 9924023: Readability review (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Responded to review. Created 8 years, 7 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
Index: net/base/priority_queue.h
diff --git a/net/base/priority_queue.h b/net/base/priority_queue.h
index f60b88c69a05319958ae80eb97db603cda350484..5622fe519d5ece6892f3fbb8e833e7f95d3e693f 100644
--- a/net/base/priority_queue.h
+++ b/net/base/priority_queue.h
@@ -34,7 +34,7 @@ class PriorityQueue : public base::NonThreadSafe {
private:
// This section is up-front for Pointer only.
#if !defined(NDEBUG)
- typedef std::list<std::pair<size_t, T> > List;
+ typedef std::list<std::pair<unsigned, T> > List;
#else
typedef std::list<T> List;
#endif
@@ -49,10 +49,26 @@ class PriorityQueue : public base::NonThreadSafe {
// Constructs a null pointer.
Pointer() : priority_(kNullPriority) {
#if !defined(NDEBUG)
- id_ = static_cast<size_t>(-1);
+ id_ = static_cast<unsigned>(-1);
#endif
}
+ Pointer(const Pointer& p) : priority_(p.priority_), iterator_(p.iterator_) {
+#if !defined(NDEBUG)
+ id_ = p.id_;
+#endif
+ }
+
+ Pointer& operator=(const Pointer& p) {
+ // Self-assignment is benign.
+ priority_ = p.priority_;
+ iterator_ = p.iterator_;
+#if !defined(NDEBUG)
+ id_ = p.id_;
+#endif
+ return *this;
+ }
+
bool is_null() const { return priority_ == kNullPriority; }
Priority priority() const { return priority_; }
@@ -94,7 +110,7 @@ class PriorityQueue : public base::NonThreadSafe {
#if !defined(NDEBUG)
// Used by the queue to check if a Pointer is valid.
- size_t id_;
+ unsigned id_;
#endif
};
@@ -114,7 +130,7 @@ class PriorityQueue : public base::NonThreadSafe {
++size_;
List& list = lists_[priority];
#if !defined(NDEBUG)
- size_t id = next_id_;
+ unsigned id = next_id_;
valid_ids_.insert(id);
++next_id_;
return Pointer(priority, list.insert(list.end(),
@@ -208,15 +224,18 @@ class PriorityQueue : public base::NonThreadSafe {
typedef std::vector<List> ListVector;
#if !defined(NDEBUG)
- size_t next_id_;
- base::hash_set<size_t> valid_ids_;
+ unsigned next_id_;
+ base::hash_set<unsigned> valid_ids_;
#endif
ListVector lists_;
size_t size_;
+
+ DISALLOW_COPY_AND_ASSIGN(PriorityQueue);
};
} // namespace net
#endif // NET_BASE_PRIORITY_QUEUE_H_
+

Powered by Google App Engine
This is Rietveld 408576698