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

Side by Side Diff: src/uri.h

Issue 430503007: Rename ASSERT* to DCHECK*. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE and fixes Created 6 years, 4 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 | « src/unique.h ('k') | src/utils.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project 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 #ifndef V8_URI_H_ 5 #ifndef V8_URI_H_
6 #define V8_URI_H_ 6 #define V8_URI_H_
7 7
8 #include "src/v8.h" 8 #include "src/v8.h"
9 9
10 #include "src/conversions.h" 10 #include "src/conversions.h"
11 #include "src/string-search.h" 11 #include "src/string-search.h"
12 #include "src/utils.h" 12 #include "src/utils.h"
13 13
14 namespace v8 { 14 namespace v8 {
15 namespace internal { 15 namespace internal {
16 16
17 17
18 template <typename Char> 18 template <typename Char>
19 static INLINE(Vector<const Char> GetCharVector(Handle<String> string)); 19 static INLINE(Vector<const Char> GetCharVector(Handle<String> string));
20 20
21 21
22 template <> 22 template <>
23 Vector<const uint8_t> GetCharVector(Handle<String> string) { 23 Vector<const uint8_t> GetCharVector(Handle<String> string) {
24 String::FlatContent flat = string->GetFlatContent(); 24 String::FlatContent flat = string->GetFlatContent();
25 ASSERT(flat.IsAscii()); 25 DCHECK(flat.IsAscii());
26 return flat.ToOneByteVector(); 26 return flat.ToOneByteVector();
27 } 27 }
28 28
29 29
30 template <> 30 template <>
31 Vector<const uc16> GetCharVector(Handle<String> string) { 31 Vector<const uc16> GetCharVector(Handle<String> string) {
32 String::FlatContent flat = string->GetFlatContent(); 32 String::FlatContent flat = string->GetFlatContent();
33 ASSERT(flat.IsTwoByte()); 33 DCHECK(flat.IsTwoByte());
34 return flat.ToUC16Vector(); 34 return flat.ToUC16Vector();
35 } 35 }
36 36
37 37
38 class URIUnescape : public AllStatic { 38 class URIUnescape : public AllStatic {
39 public: 39 public:
40 template<typename Char> 40 template<typename Char>
41 MUST_USE_RESULT static MaybeHandle<String> Unescape(Isolate* isolate, 41 MUST_USE_RESULT static MaybeHandle<String> Unescape(Isolate* isolate,
42 Handle<String> source); 42 Handle<String> source);
43 43
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 for (int i = start_index; i < length; unescaped_length++) { 93 for (int i = start_index; i < length; unescaped_length++) {
94 int step; 94 int step;
95 if (UnescapeChar(vector, i, length, &step) > 95 if (UnescapeChar(vector, i, length, &step) >
96 String::kMaxOneByteCharCode) { 96 String::kMaxOneByteCharCode) {
97 one_byte = false; 97 one_byte = false;
98 } 98 }
99 i += step; 99 i += step;
100 } 100 }
101 } 101 }
102 102
103 ASSERT(start_index < length); 103 DCHECK(start_index < length);
104 Handle<String> first_part = 104 Handle<String> first_part =
105 isolate->factory()->NewProperSubString(string, 0, start_index); 105 isolate->factory()->NewProperSubString(string, 0, start_index);
106 106
107 int dest_position = 0; 107 int dest_position = 0;
108 Handle<String> second_part; 108 Handle<String> second_part;
109 ASSERT(unescaped_length <= String::kMaxLength); 109 DCHECK(unescaped_length <= String::kMaxLength);
110 if (one_byte) { 110 if (one_byte) {
111 Handle<SeqOneByteString> dest = isolate->factory()->NewRawOneByteString( 111 Handle<SeqOneByteString> dest = isolate->factory()->NewRawOneByteString(
112 unescaped_length).ToHandleChecked(); 112 unescaped_length).ToHandleChecked();
113 DisallowHeapAllocation no_allocation; 113 DisallowHeapAllocation no_allocation;
114 Vector<const Char> vector = GetCharVector<Char>(string); 114 Vector<const Char> vector = GetCharVector<Char>(string);
115 for (int i = start_index; i < length; dest_position++) { 115 for (int i = start_index; i < length; dest_position++) {
116 int step; 116 int step;
117 dest->SeqOneByteStringSet(dest_position, 117 dest->SeqOneByteStringSet(dest_position,
118 UnescapeChar(vector, i, length, &step)); 118 UnescapeChar(vector, i, length, &step));
119 i += step; 119 i += step;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 219 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 220 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
221 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 221 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
222 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
223 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 223 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
224 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; 224 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
225 225
226 226
227 template<typename Char> 227 template<typename Char>
228 MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) { 228 MaybeHandle<String> URIEscape::Escape(Isolate* isolate, Handle<String> string) {
229 ASSERT(string->IsFlat()); 229 DCHECK(string->IsFlat());
230 int escaped_length = 0; 230 int escaped_length = 0;
231 int length = string->length(); 231 int length = string->length();
232 232
233 { DisallowHeapAllocation no_allocation; 233 { DisallowHeapAllocation no_allocation;
234 Vector<const Char> vector = GetCharVector<Char>(string); 234 Vector<const Char> vector = GetCharVector<Char>(string);
235 for (int i = 0; i < length; i++) { 235 for (int i = 0; i < length; i++) {
236 uint16_t c = vector[i]; 236 uint16_t c = vector[i];
237 if (c >= 256) { 237 if (c >= 256) {
238 escaped_length += 6; 238 escaped_length += 6;
239 } else if (IsNotEscaped(c)) { 239 } else if (IsNotEscaped(c)) {
240 escaped_length++; 240 escaped_length++;
241 } else { 241 } else {
242 escaped_length += 3; 242 escaped_length += 3;
243 } 243 }
244 244
245 // We don't allow strings that are longer than a maximal length. 245 // We don't allow strings that are longer than a maximal length.
246 ASSERT(String::kMaxLength < 0x7fffffff - 6); // Cannot overflow. 246 DCHECK(String::kMaxLength < 0x7fffffff - 6); // Cannot overflow.
247 if (escaped_length > String::kMaxLength) break; // Provoke exception. 247 if (escaped_length > String::kMaxLength) break; // Provoke exception.
248 } 248 }
249 } 249 }
250 250
251 // No length change implies no change. Return original string if no change. 251 // No length change implies no change. Return original string if no change.
252 if (escaped_length == length) return string; 252 if (escaped_length == length) return string;
253 253
254 Handle<SeqOneByteString> dest; 254 Handle<SeqOneByteString> dest;
255 ASSIGN_RETURN_ON_EXCEPTION( 255 ASSIGN_RETURN_ON_EXCEPTION(
256 isolate, dest, 256 isolate, dest,
(...skipping 24 matching lines...) Expand all
281 } 281 }
282 } 282 }
283 } 283 }
284 284
285 return dest; 285 return dest;
286 } 286 }
287 287
288 } } // namespace v8::internal 288 } } // namespace v8::internal
289 289
290 #endif // V8_URI_H_ 290 #endif // V8_URI_H_
OLDNEW
« no previous file with comments | « src/unique.h ('k') | src/utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698