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

Side by Side Diff: content/common/indexed_db/indexed_db_key.cc

Issue 202863004: Fix "unreachable code" warnings (MSVC warning 4702) in content/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/common/indexed_db/indexed_db_key.h" 5 #include "content/common/indexed_db/indexed_db_key.h"
6 6
7 #include <string> 7 #include <string>
8 #include "base/logging.h" 8 #include "base/logging.h"
9 9
10 namespace content { 10 namespace content {
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 return type_ > other.type_ ? -1 : 1; 114 return type_ > other.type_ ? -1 : 1;
115 115
116 switch (type_) { 116 switch (type_) {
117 case WebIDBKeyTypeArray: 117 case WebIDBKeyTypeArray:
118 for (size_t i = 0; i < array_.size() && i < other.array_.size(); ++i) { 118 for (size_t i = 0; i < array_.size() && i < other.array_.size(); ++i) {
119 if (int result = array_[i].Compare(other.array_[i])) 119 if (int result = array_[i].Compare(other.array_[i]))
120 return result; 120 return result;
121 } 121 }
122 if (array_.size() < other.array_.size()) 122 if (array_.size() < other.array_.size())
123 return -1; 123 return -1;
124 if (array_.size() > other.array_.size()) 124 return (array_.size() > other.array_.size()) ? 1 : 0;
jam 2014/03/19 16:44:36 here, and in line 133 and 138, leave the code as i
jsbell 2014/03/19 16:52:05 I wouldn't object to a follow-up patch that introd
Peter Kasting 2014/03/19 17:50:42 133 and 138 nest ternaries, which has always been
Peter Kasting 2014/03/19 21:10:57 (Splitting this to a separate CL so this CL doesn'
125 return 1; 125
jam 2014/03/19 16:44:36 ditto
Peter Kasting 2014/03/19 21:10:57 Done.
126 return 0;
127 case WebIDBKeyTypeBinary: 126 case WebIDBKeyTypeBinary:
128 return binary_.compare(other.binary_); 127 return binary_.compare(other.binary_);
128
129 case WebIDBKeyTypeString: 129 case WebIDBKeyTypeString:
130 return string_.compare(other.string_); 130 return string_.compare(other.string_);
131
131 case WebIDBKeyTypeDate: 132 case WebIDBKeyTypeDate:
132 return (date_ < other.date_) ? -1 : (date_ > other.date_) ? 1 : 0; 133 if (date_ < other.date_)
134 return -1;
135 return (date_ > other.date_) ? 1 : 0;
136
133 case WebIDBKeyTypeNumber: 137 case WebIDBKeyTypeNumber:
134 return (number_ < other.number_) ? -1 : (number_ > other.number_) ? 1 : 0; 138 if (number_ < other.number_)
139 return -1;
140 return (number_ > other.number_) ? 1 : 0;
141
135 case WebIDBKeyTypeInvalid: 142 case WebIDBKeyTypeInvalid:
136 case WebIDBKeyTypeNull: 143 case WebIDBKeyTypeNull:
137 case WebIDBKeyTypeMin: 144 case WebIDBKeyTypeMin:
138 default: 145 default:
139 NOTREACHED(); 146 NOTREACHED();
140 return 0; 147 return 0;
141 } 148 }
142 NOTREACHED();
143 return 0;
144 } 149 }
145 150
146 bool IndexedDBKey::IsLessThan(const IndexedDBKey& other) const { 151 bool IndexedDBKey::IsLessThan(const IndexedDBKey& other) const {
147 return Compare(other) < 0; 152 return Compare(other) < 0;
148 } 153 }
149 154
150 bool IndexedDBKey::IsEqual(const IndexedDBKey& other) const { 155 bool IndexedDBKey::IsEqual(const IndexedDBKey& other) const {
151 return !Compare(other); 156 return !Compare(other);
152 } 157 }
153 158
154 bool IndexedDBKey::IsValid() const { 159 bool IndexedDBKey::IsValid() const {
155 if (type_ == WebIDBKeyTypeInvalid || type_ == WebIDBKeyTypeNull) 160 if (type_ == WebIDBKeyTypeInvalid || type_ == WebIDBKeyTypeNull)
156 return false; 161 return false;
157 162
158 if (type_ == WebIDBKeyTypeArray) { 163 if (type_ == WebIDBKeyTypeArray) {
159 for (size_t i = 0; i < array_.size(); i++) { 164 for (size_t i = 0; i < array_.size(); i++) {
160 if (!array_[i].IsValid()) 165 if (!array_[i].IsValid())
161 return false; 166 return false;
162 } 167 }
163 } 168 }
164 169
165 return true; 170 return true;
166 } 171 }
167 172
168 } // namespace content 173 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698