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

Side by Side Diff: src/uri.h

Issue 223593004: Revert "Return MaybeHandle from NewConsString." (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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 MaybeHandle<String> Unescape(Isolate* isolate, Handle<String> source); 64 static Handle<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 MaybeHandle<String> UnescapeSlow( 70 static Handle<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 MaybeHandle<String> URIUnescape::Unescape(Isolate* isolate, 94 Handle<String> URIUnescape::Unescape(Isolate* isolate, Handle<String> source) {
95 Handle<String> source) {
96 int index; 95 int index;
97 { DisallowHeapAllocation no_allocation; 96 { DisallowHeapAllocation no_allocation;
98 StringSearch<uint8_t, Char> search(isolate, STATIC_ASCII_VECTOR("%")); 97 StringSearch<uint8_t, Char> search(isolate, STATIC_ASCII_VECTOR("%"));
99 index = search.Search(GetCharVector<Char>(source), 0); 98 index = search.Search(GetCharVector<Char>(source), 0);
100 if (index < 0) return source; 99 if (index < 0) return source;
101 } 100 }
102 return UnescapeSlow<Char>(isolate, source, index); 101 return UnescapeSlow<Char>(isolate, source, index);
103 } 102 }
104 103
105 104
106 template <typename Char> 105 template <typename Char>
107 MaybeHandle<String> URIUnescape::UnescapeSlow( 106 Handle<String> URIUnescape::UnescapeSlow(
108 Isolate* isolate, Handle<String> string, int start_index) { 107 Isolate* isolate, Handle<String> string, int start_index) {
109 bool one_byte = true; 108 bool one_byte = true;
110 int length = string->length(); 109 int length = string->length();
111 110
112 int unescaped_length = 0; 111 int unescaped_length = 0;
113 { DisallowHeapAllocation no_allocation; 112 { DisallowHeapAllocation no_allocation;
114 Vector<const Char> vector = GetCharVector<Char>(string); 113 Vector<const Char> vector = GetCharVector<Char>(string);
115 for (int i = start_index; i < length; unescaped_length++) { 114 for (int i = start_index; i < length; unescaped_length++) {
116 int step; 115 int step;
117 if (UnescapeChar(vector, i, length, &step) > 116 if (UnescapeChar(vector, i, length, &step) >
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 } 301 }
303 } 302 }
304 } 303 }
305 304
306 return dest; 305 return dest;
307 } 306 }
308 307
309 } } // namespace v8::internal 308 } } // namespace v8::internal
310 309
311 #endif // V8_URI_H_ 310 #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