cc3b3f4976
25 hits in FluteComplex. Many come from APIs with `[start, end)` range arguments that are unused so `length = end - start` is now optimized to `end`. Change-Id: I59527f85323bed717d62249f0c1d69b477645ec2 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/360444 Commit-Queue: Stephen Adams <sra@google.com> Reviewed-by: Nate Biggs <natebiggs@google.com>
116 lines
2.2 KiB
Dart
116 lines
2.2 KiB
Dart
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
// Generally, we can replace `a - b` with `a` when `a` is a number and `b` is
|
|
// zero.
|
|
//
|
|
// The exception is when both operands are negative zero: `(-0.0) - (-0.0)`
|
|
// results in a non-negative zero.
|
|
//
|
|
// With web numbers, the value `-0.0` is recognized as an integer so can occur
|
|
// as a constant right operand, usually by constant-folding.
|
|
|
|
/*member: main:ignore*/
|
|
void main() {
|
|
for (final a in [
|
|
C(),
|
|
0,
|
|
-0.0,
|
|
1,
|
|
-1,
|
|
1.1,
|
|
-1.1,
|
|
double.nan,
|
|
double.infinity,
|
|
double.negativeInfinity,
|
|
]) {
|
|
sink.add(whenDynamic(a));
|
|
|
|
if (a is int) {
|
|
sink.add(whenInt1(a));
|
|
sink.add(whenInt2(a));
|
|
}
|
|
if (a is double) {
|
|
sink.add(whenDouble1(a));
|
|
sink.add(whenDouble2(a));
|
|
}
|
|
if (a is num) {
|
|
sink.add(whenNum1(a));
|
|
sink.add(whenNum2(a));
|
|
sink.add(whenNum3(a));
|
|
}
|
|
}
|
|
}
|
|
|
|
final List<Object?> sink = [];
|
|
|
|
@pragma('dart2js:never-inline')
|
|
/*member: whenDynamic:function(thing) {
|
|
return J.$sub$n(thing, 0);
|
|
}*/
|
|
whenDynamic(dynamic thing) {
|
|
return thing - 0;
|
|
}
|
|
|
|
@pragma('dart2js:never-inline')
|
|
/*member: whenInt1:function(a) {
|
|
return a;
|
|
}*/
|
|
int whenInt1(int a) {
|
|
return a - 0;
|
|
}
|
|
|
|
@pragma('dart2js:never-inline')
|
|
/*member: whenInt2:function(a) {
|
|
return a - -0.0;
|
|
}*/
|
|
int whenInt2(int a) {
|
|
return a - (-0);
|
|
}
|
|
|
|
@pragma('dart2js:never-inline')
|
|
/*member: whenDouble1:function(a) {
|
|
return a;
|
|
}*/
|
|
double whenDouble1(double a) {
|
|
return a - 0;
|
|
}
|
|
|
|
@pragma('dart2js:never-inline')
|
|
/*member: whenDouble2:function(a) {
|
|
return a - -0.0;
|
|
}*/
|
|
double whenDouble2(double a) {
|
|
return a - (-0.0);
|
|
}
|
|
|
|
@pragma('dart2js:never-inline')
|
|
/*member: whenNum1:function(a) {
|
|
return a;
|
|
}*/
|
|
num whenNum1(num a) {
|
|
return a - 0;
|
|
}
|
|
|
|
@pragma('dart2js:never-inline')
|
|
/*member: whenNum2:function(a) {
|
|
return a - -0.0;
|
|
}*/
|
|
num whenNum2(num a) {
|
|
return a - (-0);
|
|
}
|
|
|
|
@pragma('dart2js:never-inline')
|
|
/*member: whenNum3:function(a) {
|
|
return a - -0.0;
|
|
}*/
|
|
num whenNum3(num a) {
|
|
return a - (-0.0);
|
|
}
|
|
|
|
class C {
|
|
/*member: C.-:ignore*/
|
|
C operator -(int i) => this;
|
|
}
|