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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/unibrow.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/unibrow-inl.h
diff --git a/runtime/vm/unibrow-inl.h b/runtime/vm/unibrow-inl.h
new file mode 100644
index 0000000000000000000000000000000000000000..a7e3b22d00811961b981ac0f405cf5bca2966e6c
--- /dev/null
+++ b/runtime/vm/unibrow-inl.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef VM_UNIBROW_INL_H_
+#define VM_UNIBROW_INL_H_
+
+#include "vm/unibrow.h"
+
+// SNIP
+
+namespace unibrow {
+
+// SNIP
+
+template <class T, int s> int Mapping<T, s>::get(uchar c, uchar n,
+ uchar* result) {
+ CacheEntry entry = entries_[c & kMask];
+ if (entry.code_point_ == c) {
+ if (entry.offset_ == 0) {
+ return 0;
+ } else {
+ result[0] = c + entry.offset_;
+ return 1;
+ }
+ } else {
+ return CalculateValue(c, n, result);
+ }
+}
+
+template <class T, int s> int Mapping<T, s>::CalculateValue(uchar c, uchar n,
+ uchar* result) {
+ bool allow_caching = true;
+ int length = T::Convert(c, n, result, &allow_caching);
+ if (allow_caching) {
+ if (length == 1) {
+ entries_[c & kMask] = CacheEntry(c, result[0] - c);
+ return 1;
+ } else {
+ entries_[c & kMask] = CacheEntry(c, 0);
+ return 0;
+ }
+ } else {
+ return length;
+ }
+}
+
+// SNIP
+
+} // namespace unibrow
+
+#endif // VM_UNIBROW_INL_H_
« 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