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

Side by Side Diff: base/json/json_reader.cc

Issue 8312004: base/json: Collapse a condition in ReadHexDigits into a single if clause. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 6
7 #include "base/float_util.h" 7 #include "base/float_util.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stringprintf.h" 10 #include "base/stringprintf.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 44
45 return true; 45 return true;
46 } 46 }
47 47
48 // A helper method for ParseStringToken. It reads |digits| hex digits from the 48 // A helper method for ParseStringToken. It reads |digits| hex digits from the
49 // token. If the sequence if digits is not valid (contains other characters), 49 // token. If the sequence if digits is not valid (contains other characters),
50 // the method returns false. 50 // the method returns false.
51 bool ReadHexDigits(base::JSONReader::Token& token, int digits) { 51 bool ReadHexDigits(base::JSONReader::Token& token, int digits) {
52 for (int i = 1; i <= digits; ++i) { 52 for (int i = 1; i <= digits; ++i) {
53 wchar_t c = *(token.begin + token.length + i); 53 wchar_t c = *(token.begin + token.length + i);
54 if ('\0' == c) 54 if (c == '\0' || !IsHexDigit(c))
55 return false;
56 if (!IsHexDigit(c))
57 return false; 55 return false;
58 } 56 }
59 57
60 token.length += digits; 58 token.length += digits;
61 return true; 59 return true;
62 } 60 }
63 61
64 } // namespace 62 } // namespace
65 63
66 namespace base { 64 namespace base {
(...skipping 592 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 ++column_number; 657 ++column_number;
660 } 658 }
661 } 659 }
662 660
663 error_line_ = line_number; 661 error_line_ = line_number;
664 error_col_ = column_number; 662 error_col_ = column_number;
665 error_code_ = error; 663 error_code_ = error;
666 } 664 }
667 665
668 } // namespace base 666 } // namespace base
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698