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

Side by Side Diff: src/uri.h

Issue 223383002: Return MaybeHandle from NewConsString. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comment Created 6 years, 8 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/runtime.cc ('k') | test/cctest/test-heap-profiler.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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 Vector<const uc16> GetCharVector(Handle<String> string) { 54 Vector<const uc16> GetCharVector(Handle<String> string) {
55 String::FlatContent flat = string->GetFlatContent(); 55 String::FlatContent flat = string->GetFlatContent();
56 ASSERT(flat.IsTwoByte()); 56 ASSERT(flat.IsTwoByte());
57 return flat.ToUC16Vector(); 57 return flat.ToUC16Vector();
58 } 58 }
59 59
60 60
61 class URIUnescape : public AllStatic { 61 class URIUnescape : public AllStatic {
62 public: 62 public:
63 template<typename Char> 63 template<typename Char>
64 static Handle<String> Unescape(Isolate* isolate, Handle<String> source); 64 static MaybeHandle<String> Unescape(Isolate* isolate, Handle<String> source);
65 65
66 private: 66 private:
67 static const signed char kHexValue['g']; 67 static const signed char kHexValue['g'];
68 68
69 template<typename Char> 69 template<typename Char>
70 static Handle<String> UnescapeSlow( 70 static MaybeHandle<String> UnescapeSlow(
71 Isolate* isolate, Handle<String> string, int start_index); 71 Isolate* isolate, Handle<String> string, int start_index);
72 72
73 static INLINE(int TwoDigitHex(uint16_t character1, uint16_t character2)); 73 static INLINE(int TwoDigitHex(uint16_t character1, uint16_t character2));
74 74
75 template <typename Char> 75 template <typename Char>
76 static INLINE(int UnescapeChar(Vector<const Char> vector, 76 static INLINE(int UnescapeChar(Vector<const Char> vector,
77 int i, 77 int i,
78 int length, 78 int length,
79 int* step)); 79 int* step));
80 }; 80 };
81 81
82 82
83 const signed char URIUnescape::kHexValue[] = { 83 const signed char URIUnescape::kHexValue[] = {
84 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 84 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
85 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 85 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
86 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 86 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
87 -0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, 87 -0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1,
88 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, 88 -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1,
89 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 89 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
90 -1, 10, 11, 12, 13, 14, 15 }; 90 -1, 10, 11, 12, 13, 14, 15 };
91 91
92 92
93 template<typename Char> 93 template<typename Char>
94 Handle<String> URIUnescape::Unescape(Isolate* isolate, Handle<String> source) { 94 MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate,
95 Handle<String> source) {
95 int index; 96 int index;
96 { DisallowHeapAllocation no_allocation; 97 { DisallowHeapAllocation no_allocation;
97 StringSearch<uint8_t, Char> search(isolate, STATIC_ASCII_VECTOR("%")); 98 StringSearch<uint8_t, Char> search(isolate, STATIC_ASCII_VECTOR("%"));
98 index = search.Search(GetCharVector<Char>(source), 0); 99 index = search.Search(GetCharVector<Char>(source), 0);
99 if (index < 0) return source; 100 if (index < 0) return source;
100 } 101 }
101 return UnescapeSlow<Char>(isolate, source, index); 102 return UnescapeSlow<Char>(isolate, source, index);
102 } 103 }
103 104
104 105
105 template <typename Char> 106 template <typename Char>
106 Handle<String> URIUnescape::UnescapeSlow( 107 MaybeHandle<String> URIUnescape::UnescapeSlow(
107 Isolate* isolate, Handle<String> string, int start_index) { 108 Isolate* isolate, Handle<String> string, int start_index) {
108 bool one_byte = true; 109 bool one_byte = true;
109 int length = string->length(); 110 int length = string->length();
110 111
111 int unescaped_length = 0; 112 int unescaped_length = 0;
112 { DisallowHeapAllocation no_allocation; 113 { DisallowHeapAllocation no_allocation;
113 Vector<const Char> vector = GetCharVector<Char>(string); 114 Vector<const Char> vector = GetCharVector<Char>(string);
114 for (int i = start_index; i < length; unescaped_length++) { 115 for (int i = start_index; i < length; unescaped_length++) {
115 int step; 116 int step;
116 if (UnescapeChar(vector, i, length, &step) > 117 if (UnescapeChar(vector, i, length, &step) >
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 } 302 }
302 } 303 }
303 } 304 }
304 305
305 return dest; 306 return dest;
306 } 307 }
307 308
308 } } // namespace v8::internal 309 } } // namespace v8::internal
309 310
310 #endif // V8_URI_H_ 311 #endif // V8_URI_H_
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | test/cctest/test-heap-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698