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

Unified Diff: runtime/lib/string_patch.dart

Issue 15709018: Proof-of-concept matchPrefix on Pattern. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed other comments. Created 7 years, 6 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
« no previous file with comments | « runtime/lib/regexp_patch.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/interceptors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string_patch.dart
diff --git a/runtime/lib/string_patch.dart b/runtime/lib/string_patch.dart
index 16c3232c4a0ba1c02ac0b597c7c07314ba7f9762..4612571698742625156e02be247ccb164c825241 100644
--- a/runtime/lib/string_patch.dart
+++ b/runtime/lib/string_patch.dart
@@ -421,6 +421,19 @@ class _StringBase {
return result;
}
+ Match matchAsPrefix(String string, [int start = 0]) {
+ if (start < 0 || start > string.length) {
+ throw new RangeError.range(start, 0, string.length);
+ }
+ if (start + this.length > string.length) return null;
+ for (int i = 0; i < this.length; i++) {
+ if (string.codeUnitAt(start + i) != this.codeUnitAt(i)) {
+ return null;
+ }
+ }
+ return new _StringMatch(start, string, this);
+ }
+
List<String> split(Pattern pattern) {
if ((pattern is String) && pattern.isEmpty) {
List<String> result = new List<String>(length);
« no previous file with comments | « runtime/lib/regexp_patch.dart ('k') | sdk/lib/_internal/compiler/implementation/lib/interceptors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698