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

Side by Side Diff: net/base/escape.cc

Issue 10942004: Cleanup: avoid foo ? true : false, part 2. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 3 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 | net/disk_cache/bitmap.cc » ('j') | 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) 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 "net/base/escape.h" 5 #include "net/base/escape.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 12 matching lines...) Expand all
23 DCHECK_LE(i, 15) << i << " not a hex value"; 23 DCHECK_LE(i, 15) << i << " not a hex value";
24 return kHexString[i]; 24 return kHexString[i];
25 } 25 }
26 26
27 // A fast bit-vector map for ascii characters. 27 // A fast bit-vector map for ascii characters.
28 // 28 //
29 // Internally stores 256 bits in an array of 8 ints. 29 // Internally stores 256 bits in an array of 8 ints.
30 // Does quick bit-flicking to lookup needed characters. 30 // Does quick bit-flicking to lookup needed characters.
31 struct Charmap { 31 struct Charmap {
32 bool Contains(unsigned char c) const { 32 bool Contains(unsigned char c) const {
33 return (map[c >> 5] & (1 << (c & 31))) ? true : false; 33 return ((map[c >> 5] & (1 << (c & 31))) != 0);
34 } 34 }
35 35
36 uint32 map[8]; 36 uint32 map[8];
37 }; 37 };
38 38
39 // Given text to escape and a Charmap defining which values to escape, 39 // Given text to escape and a Charmap defining which values to escape,
40 // return an escaped string. If use_plus is true, spaces are converted 40 // return an escaped string. If use_plus is true, spaces are converted
41 // to +, otherwise, if spaces are in the charmap, they are converted to 41 // to +, otherwise, if spaces are in the charmap, they are converted to
42 // %20. 42 // %20.
43 std::string Escape(const std::string& text, const Charmap& charmap, 43 std::string Escape(const std::string& text, const Charmap& charmap,
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 return; 380 return;
381 } 381 }
382 adjusted_offset -= 2; 382 adjusted_offset -= 2;
383 } 383 }
384 offset = adjusted_offset; 384 offset = adjusted_offset;
385 } 385 }
386 386
387 } // namespace internal 387 } // namespace internal
388 388
389 } // namespace net 389 } // namespace net
OLDNEW
« no previous file with comments | « no previous file | net/disk_cache/bitmap.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698