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

Unified Diff: sdk/lib/_internal/compiler/js_lib/string_helper.dart

Issue 917663004: Revert "Add String.replaceFirstMapped." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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 | « sdk/lib/_internal/compiler/js_lib/js_string.dart ('k') | sdk/lib/core/string.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sdk/lib/_internal/compiler/js_lib/string_helper.dart
diff --git a/sdk/lib/_internal/compiler/js_lib/string_helper.dart b/sdk/lib/_internal/compiler/js_lib/string_helper.dart
index 77b8ab9c34a95b95cb4c4c44604578362ffed8ee..ff2505729a1b3cce8352be876681941925776479 100644
--- a/sdk/lib/_internal/compiler/js_lib/string_helper.dart
+++ b/sdk/lib/_internal/compiler/js_lib/string_helper.dart
@@ -193,34 +193,21 @@ stringReplaceAllStringFuncUnchecked(receiver, pattern, onMatch, onNonMatch) {
}
-stringReplaceFirstUnchecked(receiver, from, to, int startIndex) {
+stringReplaceFirstUnchecked(receiver, from, to, [int startIndex = 0]) {
if (from is String) {
- int index = receiver.indexOf(from, startIndex);
+ var index = receiver.indexOf(from, startIndex);
if (index < 0) return receiver;
return '${receiver.substring(0, index)}$to'
'${receiver.substring(index + from.length)}';
- }
- if (from is JSSyntaxRegExp) {
+ } else if (from is JSSyntaxRegExp) {
return startIndex == 0 ?
stringReplaceJS(receiver, regExpGetNative(from), to) :
stringReplaceFirstRE(receiver, from, to, startIndex);
+ } else {
+ checkNull(from);
+ // TODO(floitsch): implement generic String.replace (with patterns).
+ throw "String.replace(Pattern) UNIMPLEMENTED";
}
- checkNull(from);
- Iterator<Match> matches = from.allMatches(receiver, startIndex).iterator;
- if (!matches.moveNext()) return receiver;
- Match match = matches.current;
- return '${receiver.substring(0, match.start)}$to'
- '${receiver.substring(match.end)}';
-}
-
-stringReplaceFirstMappedUnchecked(receiver, from, replace,
- int startIndex) {
- Iterator<Match> matches = from.allMatches(receiver, startIndex).iterator;
- if (!matches.moveNext()) return receiver;
- Match match = matches.current;
- String replacement = "${replace(match)}";
- return '${receiver.substring(0, match.start)}$replacement'
- '${receiver.substring(match.end)}';
}
stringJoinUnchecked(array, separator) {
« no previous file with comments | « sdk/lib/_internal/compiler/js_lib/js_string.dart ('k') | sdk/lib/core/string.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698