mirror of
https://github.com/dart-lang/sdk
synced 2024-11-02 15:17:07 +00:00
[dart2wasm] Use the same Dart object when to{Upper,Lower}Case returns the argument
This fixes `identical` checks when the input doesn't need case mapping. This change was originally made in [1], but I'm trying to split it into smaller CLs as it currently has a lot of conflicts with the main branch. [1]: https://dart-review.googlesource.com/c/sdk/+/316628 Change-Id: I88da52a3a73c9d587acefe2b14fd39edaf01c966 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/332200 Reviewed-by: Aske Simon Christensen <askesc@google.com> Commit-Queue: Ömer Ağacan <omersa@google.com>
This commit is contained in:
parent
12c4e22a4d
commit
d0a2656611
1 changed files with 13 additions and 4 deletions
|
@ -319,14 +319,20 @@ final class JSStringImpl implements String {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toLowerCase() {
|
String toLowerCase() {
|
||||||
return JSStringImpl(
|
final thisRef = toExternRef;
|
||||||
js.JS<WasmExternRef?>('s => s.toLowerCase()', toExternRef));
|
final lowerCaseRef = js.JS<WasmExternRef?>('s => s.toLowerCase()', thisRef);
|
||||||
|
return _jsIdentical(thisRef, lowerCaseRef)
|
||||||
|
? this
|
||||||
|
: JSStringImpl(lowerCaseRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toUpperCase() {
|
String toUpperCase() {
|
||||||
return JSStringImpl(
|
final thisRef = toExternRef;
|
||||||
js.JS<WasmExternRef?>('s => s.toUpperCase()', toExternRef));
|
final upperCaseRef = js.JS<WasmExternRef?>('s => s.toUpperCase()', thisRef);
|
||||||
|
return _jsIdentical(thisRef, upperCaseRef)
|
||||||
|
? this
|
||||||
|
: JSStringImpl(upperCaseRef);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Characters with Whitespace property (Unicode 6.3).
|
// Characters with Whitespace property (Unicode 6.3).
|
||||||
|
@ -679,3 +685,6 @@ JSStringImpl _jsStringToJSStringImpl(WasmExternRef? string) =>
|
||||||
@pragma("wasm:export", "\$jsStringFromJSStringImpl")
|
@pragma("wasm:export", "\$jsStringFromJSStringImpl")
|
||||||
WasmExternRef? _jsStringFromJSStringImpl(JSStringImpl string) =>
|
WasmExternRef? _jsStringFromJSStringImpl(JSStringImpl string) =>
|
||||||
string.toExternRef;
|
string.toExternRef;
|
||||||
|
|
||||||
|
bool _jsIdentical(WasmExternRef? ref1, WasmExternRef? ref2) =>
|
||||||
|
js.JS<bool>('Object.is', ref1, ref2);
|
||||||
|
|
Loading…
Reference in a new issue