Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 3af9638

Browse files
Markzipancommit-bot@chromium.org
authored andcommitted
[dartdevc] Removing redundant String concat operations.
These were apparently copied from Dart2JS but never inlined in DDC, so they've been pure overhead. Change-Id: I614a94d130248bece5ba7af8c5b9a436b1196b62 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/164682 Commit-Queue: Mark Zhou <markzipan@google.com> Reviewed-by: Nicholas Shahan <nshahan@google.com>
1 parent ffbe30f commit 3af9638

File tree

3 files changed

+5
-18
lines changed

3 files changed

+5
-18
lines changed

sdk/lib/_internal/js_dev_runtime/patch/core_patch.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -732,8 +732,8 @@ class StringBuffer {
732732
@patch
733733
String toString() => Primitives.flattenString(_contents);
734734

735-
void _writeString(String str) {
736-
_contents = Primitives.stringConcatUnchecked(_contents, str);
735+
void _writeString(@notNull String str) {
736+
_contents = JS<String>('!', '# + #', _contents, str);
737737
}
738738

739739
static String _writeAll(String string, Iterable objects, String separator) {
@@ -753,8 +753,8 @@ class StringBuffer {
753753
return string;
754754
}
755755

756-
static String _writeOne(String string, Object? obj) {
757-
return Primitives.stringConcatUnchecked(string, '$obj');
756+
static String _writeOne(@notNull String string, Object? obj) {
757+
return JS<String>('!', '# + #', string, '$obj');
758758
}
759759
}
760760

sdk/lib/_internal/js_dev_runtime/private/foreign_helper.dart

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,6 @@ class JS_CONST {
259259
const JS_CONST(this.code);
260260
}
261261

262-
/**
263-
* JavaScript string concatenation. Inputs must be Strings. Corresponds to the
264-
* HStringConcat SSA instruction and may be constant-folded.
265-
*/
266-
String JS_STRING_CONCAT(String a, String b) {
267-
// This body is unused, only here for type analysis.
268-
return JS<String>('!', '# + #', a, b);
269-
}
270-
271262
/// Same `@rest` annotation and `spread` function as in
272263
/// `package:js/src/varargs.dart`.
273264
///

sdk/lib/_internal/js_dev_runtime/private/js_helper.dart

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ library dart._js_helper;
66

77
import 'dart:collection';
88

9-
import 'dart:_foreign_helper' show JS, JS_STRING_CONCAT, JSExportName;
9+
import 'dart:_foreign_helper' show JS, JSExportName;
1010

1111
import 'dart:_interceptors';
1212
import 'dart:_internal'
@@ -295,10 +295,6 @@ class Primitives {
295295
throw RangeError.range(charCode, 0, 0x10ffff);
296296
}
297297

298-
static String stringConcatUnchecked(String string1, String string2) {
299-
return JS_STRING_CONCAT(string1, string2);
300-
}
301-
302298
static String flattenString(String str) {
303299
return JS<String>('!', "#.charCodeAt(0) == 0 ? # : #", str, str, str);
304300
}

0 commit comments

Comments
 (0)