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

Side by Side Diff: base/test/trace_event_analyzer.cc

Issue 202993003: Fix "unreachable code" warnings (MSVC warning 4702) in base/. (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 "base/test/trace_event_analyzer.h" 5 #include "base/test/trace_event_analyzer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <math.h> 8 #include <math.h>
9 #include <set> 9 #include <set>
10 10
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 // It's a logical operator. 274 // It's a logical operator.
275 switch (operator_) { 275 switch (operator_) {
276 case OP_AND: 276 case OP_AND:
277 return left().Evaluate(event) && right().Evaluate(event); 277 return left().Evaluate(event) && right().Evaluate(event);
278 case OP_OR: 278 case OP_OR:
279 return left().Evaluate(event) || right().Evaluate(event); 279 return left().Evaluate(event) || right().Evaluate(event);
280 case OP_NOT: 280 case OP_NOT:
281 return !left().Evaluate(event); 281 return !left().Evaluate(event);
282 default: 282 default:
283 NOTREACHED(); 283 NOTREACHED();
284 return false;
284 } 285 }
285
286 NOTREACHED();
287 return false;
288 } 286 }
289 287
290 bool Query::CompareAsDouble(const TraceEvent& event, bool* result) const { 288 bool Query::CompareAsDouble(const TraceEvent& event, bool* result) const {
291 double lhs, rhs; 289 double lhs, rhs;
292 if (!left().GetAsDouble(event, &lhs) || !right().GetAsDouble(event, &rhs)) 290 if (!left().GetAsDouble(event, &lhs) || !right().GetAsDouble(event, &rhs))
293 return false; 291 return false;
294 switch (operator_) { 292 switch (operator_) {
295 case OP_EQ: 293 case OP_EQ:
296 *result = (lhs == rhs); 294 *result = (lhs == rhs);
297 return true; 295 return true;
298 case OP_NE: 296 case OP_NE:
299 *result = (lhs != rhs); 297 *result = (lhs != rhs);
300 return true; 298 return true;
301 case OP_LT: 299 case OP_LT:
302 *result = (lhs < rhs); 300 *result = (lhs < rhs);
303 return true; 301 return true;
304 case OP_LE: 302 case OP_LE:
305 *result = (lhs <= rhs); 303 *result = (lhs <= rhs);
306 return true; 304 return true;
307 case OP_GT: 305 case OP_GT:
308 *result = (lhs > rhs); 306 *result = (lhs > rhs);
309 return true; 307 return true;
310 case OP_GE: 308 case OP_GE:
311 *result = (lhs >= rhs); 309 *result = (lhs >= rhs);
312 return true; 310 return true;
313 default: 311 default:
314 NOTREACHED(); 312 NOTREACHED();
315 return false; 313 return false;
316 } 314 }
317 return true;
318 } 315 }
319 316
320 bool Query::CompareAsString(const TraceEvent& event, bool* result) const { 317 bool Query::CompareAsString(const TraceEvent& event, bool* result) const {
321 std::string lhs, rhs; 318 std::string lhs, rhs;
322 if (!left().GetAsString(event, &lhs) || !right().GetAsString(event, &rhs)) 319 if (!left().GetAsString(event, &lhs) || !right().GetAsString(event, &rhs))
323 return false; 320 return false;
324 switch (operator_) { 321 switch (operator_) {
325 case OP_EQ: 322 case OP_EQ:
326 if (right().is_pattern_) 323 if (right().is_pattern_)
327 *result = MatchPattern(lhs, rhs); 324 *result = MatchPattern(lhs, rhs);
(...skipping 19 matching lines...) Expand all
347 case OP_GT: 344 case OP_GT:
348 *result = (lhs > rhs); 345 *result = (lhs > rhs);
349 return true; 346 return true;
350 case OP_GE: 347 case OP_GE:
351 *result = (lhs >= rhs); 348 *result = (lhs >= rhs);
352 return true; 349 return true;
353 default: 350 default:
354 NOTREACHED(); 351 NOTREACHED();
355 return false; 352 return false;
356 } 353 }
357 return true;
358 } 354 }
359 355
360 bool Query::EvaluateArithmeticOperator(const TraceEvent& event, 356 bool Query::EvaluateArithmeticOperator(const TraceEvent& event,
361 double* num) const { 357 double* num) const {
362 DCHECK_EQ(QUERY_ARITHMETIC_OPERATOR, type_); 358 DCHECK_EQ(QUERY_ARITHMETIC_OPERATOR, type_);
363 DCHECK(left_.get()); 359 DCHECK(left_.get());
364 DCHECK(right_.get() || is_unary_operator()); 360 DCHECK(right_.get() || is_unary_operator());
365 361
366 double lhs = 0, rhs = 0; 362 double lhs = 0, rhs = 0;
367 if (!left().GetAsDouble(event, &lhs)) 363 if (!left().GetAsDouble(event, &lhs))
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
896 } 892 }
897 } 893 }
898 return false; 894 return false;
899 } 895 }
900 896
901 bool FindLastOf(const TraceEventVector& events, 897 bool FindLastOf(const TraceEventVector& events,
902 const Query& query, 898 const Query& query,
903 size_t position, 899 size_t position,
904 size_t* return_index) { 900 size_t* return_index) {
905 DCHECK(return_index); 901 DCHECK(return_index);
906 if (events.empty()) 902 for (size_t i = std::min(position + 1, events.size()); i != 0; --i) {
907 return false; 903 if (query.Evaluate(*events[i - 1])) {
908 position = (position < events.size()) ? position : events.size() - 1; 904 *return_index = i - 1;
909 for (;;) {
910 if (query.Evaluate(*events[position])) {
911 *return_index = position;
912 return true; 905 return true;
913 } 906 }
914 if (position == 0)
915 return false;
916 --position;
917 } 907 }
918 return false; 908 return false;
919 } 909 }
920 910
921 bool FindClosest(const TraceEventVector& events, 911 bool FindClosest(const TraceEventVector& events,
922 const Query& query, 912 const Query& query,
923 size_t position, 913 size_t position,
924 size_t* return_closest, 914 size_t* return_closest,
925 size_t* return_second_closest) { 915 size_t* return_second_closest) {
926 DCHECK(return_closest); 916 DCHECK(return_closest);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
964 end_position = (end_position < events.size()) ? end_position : events.size(); 954 end_position = (end_position < events.size()) ? end_position : events.size();
965 size_t count = 0u; 955 size_t count = 0u;
966 for (size_t i = begin_position; i < end_position; ++i) { 956 for (size_t i = begin_position; i < end_position; ++i) {
967 if (query.Evaluate(*events.at(i))) 957 if (query.Evaluate(*events.at(i)))
968 ++count; 958 ++count;
969 } 959 }
970 return count; 960 return count;
971 } 961 }
972 962
973 } // namespace trace_analyzer 963 } // namespace trace_analyzer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698