Chromium Code Reviews| Index: sdk/lib/_internal/compiler/implementation/lib/js_string.dart |
| diff --git a/sdk/lib/_internal/compiler/implementation/lib/js_string.dart b/sdk/lib/_internal/compiler/implementation/lib/js_string.dart |
| index 92d7c673a2a62bc8da0b152e3afa0a81c59d5bdb..9c9c4a38b43bed8fdd5373488e7f1898fc014f81 100644 |
| --- a/sdk/lib/_internal/compiler/implementation/lib/js_string.dart |
| +++ b/sdk/lib/_internal/compiler/implementation/lib/js_string.dart |
| @@ -25,6 +25,19 @@ class JSString extends Interceptor implements String, JSIndexable { |
| return allMatchesInStringUnchecked(this, str); |
| } |
| + Match matchPrefix(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++) { |
|
floitsch
2013/06/11 12:45:24
TODO that this could be made much faster.
Lasse Reichstein Nielsen
2013/06/12 09:24:05
I'm not sure it can be made that much faster. If i
sra1
2013/06/13 17:30:54
The code is pretty horrible.
dart2js inlines codeU
|
| + if (string.codeUnitAt(start + i) != this.codeUnitAt(i)) { |
| + return null; |
| + } |
| + } |
| + return new _StringMatch(start, string, this); |
| + } |
| + |
| String operator +(String other) { |
| if (other is !String) throw new ArgumentError(other); |
| return JS('String', r'# + #', this, other); |