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

Side by Side Diff: src/unicode.h

Issue 10872010: Reland regexp global optimizations. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 8 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/runtime.cc ('k') | src/unicode-inl.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 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 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 183 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 unsigned& offset); 194 unsigned& offset);
195 static inline bool EncodeAsciiCharacter(uchar c, byte* buffer, 195 static inline bool EncodeAsciiCharacter(uchar c, byte* buffer,
196 unsigned capacity, unsigned& offset); 196 unsigned capacity, unsigned& offset);
197 static inline bool EncodeNonAsciiCharacter(uchar c, byte* buffer, 197 static inline bool EncodeNonAsciiCharacter(uchar c, byte* buffer,
198 unsigned capacity, unsigned& offset); 198 unsigned capacity, unsigned& offset);
199 static inline uchar DecodeCharacter(const byte* buffer, unsigned* offset); 199 static inline uchar DecodeCharacter(const byte* buffer, unsigned* offset);
200 virtual void Rewind() = 0; 200 virtual void Rewind() = 0;
201 201
202 protected: 202 protected:
203 virtual void FillBuffer() = 0; 203 virtual void FillBuffer() = 0;
204 virtual bool BoundsCheck(unsigned offset) = 0;
204 // The number of characters left in the current buffer 205 // The number of characters left in the current buffer
205 unsigned remaining_; 206 unsigned remaining_;
206 // The current offset within the buffer 207 // The current offset within the buffer
207 unsigned cursor_; 208 unsigned cursor_;
208 // The buffer containing the decoded characters. 209 // The buffer containing the decoded characters.
209 const byte* buffer_; 210 const byte* buffer_;
210 }; 211 };
211 212
212 // --- I n p u t B u f f e r --- 213 // --- I n p u t B u f f e r ---
213 214
214 /** 215 /**
215 * Provides efficient access to encoded characters in strings. It 216 * Provides efficient access to encoded characters in strings. It
216 * does so by reading characters one block at a time, rather than one 217 * does so by reading characters one block at a time, rather than one
217 * character at a time, which gives string implementations an 218 * character at a time, which gives string implementations an
218 * opportunity to optimize the decoding. 219 * opportunity to optimize the decoding.
219 */ 220 */
220 template <class Reader, class Input = Reader*, unsigned kSize = 256> 221 template <class Reader, class Input = Reader*, unsigned kSize = 256>
221 class InputBuffer : public CharacterStream { 222 class InputBuffer : public CharacterStream {
222 public: 223 public:
223 virtual void Rewind(); 224 virtual void Rewind();
224 inline void Reset(Input input); 225 inline void Reset(Input input);
225 void Seek(unsigned position); 226 void Seek(unsigned position);
226 inline void Reset(unsigned position, Input input); 227 inline void Reset(unsigned position, Input input);
227 protected: 228 protected:
228 InputBuffer() { } 229 InputBuffer() { }
229 explicit InputBuffer(Input input) { Reset(input); } 230 explicit InputBuffer(Input input) { Reset(input); }
230 virtual void FillBuffer(); 231 virtual void FillBuffer();
232 virtual bool BoundsCheck(unsigned offset) {
233 return (buffer_ != util_buffer_) || (offset < kSize);
234 }
231 235
232 // A custom offset that can be used by the string implementation to 236 // A custom offset that can be used by the string implementation to
233 // mark progress within the encoded string. 237 // mark progress within the encoded string.
234 unsigned offset_; 238 unsigned offset_;
235 // The input string 239 // The input string
236 Input input_; 240 Input input_;
237 // To avoid heap allocation, we keep an internal buffer to which 241 // To avoid heap allocation, we keep an internal buffer to which
238 // the encoded string can write its characters. The string 242 // the encoded string can write its characters. The string
239 // implementation is free to decide whether it wants to use this 243 // implementation is free to decide whether it wants to use this
240 // buffer or not. 244 // buffer or not.
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
314 static const int kMaxWidth = 1; 318 static const int kMaxWidth = 1;
315 static int Convert(uchar c, 319 static int Convert(uchar c,
316 uchar n, 320 uchar n,
317 uchar* result, 321 uchar* result,
318 bool* allow_caching_ptr); 322 bool* allow_caching_ptr);
319 }; 323 };
320 324
321 } // namespace unibrow 325 } // namespace unibrow
322 326
323 #endif // V8_UNICODE_H_ 327 #endif // V8_UNICODE_H_
OLDNEW
« no previous file with comments | « src/runtime.cc ('k') | src/unicode-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698