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

Unified Diff: runtime/lib/string_patch.dart

Issue 539153002: Port and integrate the irregexp engine from V8 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
Index: runtime/lib/string_patch.dart
diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart
index 3ac78a8fd9404faa5724cd771666eb61053110d5..18266d18cbda9ad7b33e08023ded1b8487e50665 100644
--- a/runtime/lib/string_patch.dart
+++ b/runtime/lib/string_patch.dart
@@ -675,6 +675,20 @@ class _OneByteString extends _StringBase implements String {
return super.split(pattern);
}
+ // Loads up to 4 code units into a single integer.
+ int _codeUnitsAt(int index, int count) {
+ assert(index >= 0);
+ assert(index + count - 1 < this.length);
+ assert(0 < count && count <= 4);
+
+ int codeUnits = 0;
+ for (int i = 0; i < count; i++) {
+ codeUnits |= this.codeUnitAt(index + i) << (i * 8);
+ }
+
+ return codeUnits;
+ }
+
// All element of 'strings' must be OneByteStrings.
static _concatAll(List<String> strings, int totalLength) {
// TODO(srdjan): Improve code below and raise or eliminate the limit.
@@ -938,6 +952,20 @@ class _TwoByteString extends _StringBase implements String {
bool operator ==(Object other) {
return super == other;
}
+
+ // Loads up to 2 code units into a single integer.
+ int _codeUnitsAt(int index, int count) {
+ assert(index >= 0);
+ assert(index + count - 1 < this.length);
+ assert(0 < count && count <= 2);
+
+ int codeUnits = 0;
+ for (int i = 0; i < count; i++) {
+ codeUnits |= this.codeUnitAt(index + i) << (i * 16);
+ }
+
+ return codeUnits;
+ }
}

Powered by Google App Engine
This is Rietveld 408576698