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

Side by Side Diff: runtime/vm/unibrow-inl.h

Issue 678193004: Copy irregexp related code from V8. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: rebase Created 6 years, 1 month 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 | « runtime/vm/unibrow.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 #ifndef VM_UNIBROW_INL_H_
6 #define VM_UNIBROW_INL_H_
7
8 #include "vm/unibrow.h"
9
10 // SNIP
11
12 namespace unibrow {
13
14 // SNIP
15
16 template <class T, int s> int Mapping<T, s>::get(uchar c, uchar n,
17 uchar* result) {
18 CacheEntry entry = entries_[c & kMask];
19 if (entry.code_point_ == c) {
20 if (entry.offset_ == 0) {
21 return 0;
22 } else {
23 result[0] = c + entry.offset_;
24 return 1;
25 }
26 } else {
27 return CalculateValue(c, n, result);
28 }
29 }
30
31 template <class T, int s> int Mapping<T, s>::CalculateValue(uchar c, uchar n,
32 uchar* result) {
33 bool allow_caching = true;
34 int length = T::Convert(c, n, result, &allow_caching);
35 if (allow_caching) {
36 if (length == 1) {
37 entries_[c & kMask] = CacheEntry(c, result[0] - c);
38 return 1;
39 } else {
40 entries_[c & kMask] = CacheEntry(c, 0);
41 return 0;
42 }
43 } else {
44 return length;
45 }
46 }
47
48 // SNIP
49
50 } // namespace unibrow
51
52 #endif // VM_UNIBROW_INL_H_
OLDNEW
« no previous file with comments | « runtime/vm/unibrow.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698