DescriptionOptimize runtime code on hot methods
ochafik: this should include your internal fixes.
Here are generated diffs:
JSArray:
[dartx._get](index) {
- if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index));
- if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index));
+ if (index == null || index >= this.length || index < 0) {
+ dart.throw(_js_helper.diagnoseIndexError(this, index));
+ }
return this[index];
}
[dartx._set](index, value) {
E._check(value);
this[dartx.checkMutable]('indexed set');
- if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index));
- if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index));
+ if (index == null || index >= this.length || index < 0) {
+ dart.throw(_js_helper.diagnoseIndexError(this, index));
+ }
R=jmesserly@google.com, ochafik@google.com
JSString:
[dartx.codeUnitAt](index) {
- if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index));
- if (dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index));
- if (dart.notNull(index) >= dart.notNull(this[dartx.length])) dart.throw(_js_helper.diagnoseIndexError(this, index));
+ if (index == null || index < 0 || index >= this.length) {
+ dart.throw(_js_helper.diagnoseIndexError(this, index));
+ }
return this.charCodeAt(index);
}
[dartx.startsWith](pattern, index) {
if (index === void 0) index = 0;
- _js_helper.checkInt(index);
- if (dart.notNull(index) < 0 || dart.notNull(index) > dart.notNull(this[dartx.length])) {
+ let length = this.length;
+ if (dart.notNull(index) < 0 || index > length) {
dart.throw(new core.RangeError.range(index, 0, this[dartx.length]));
}
if (typeof pattern == 'string') {
let other = pattern;
- let otherLength = other[dartx.length];
- let endIndex = dart.notNull(index) + dart.notNull(otherLength);
- if (endIndex > dart.notNull(this[dartx.length])) return false;
+ let otherLength = other.length;
+ let endIndex = index + otherLength;
+ if (endIndex > length) return false;
return other == this.substring(index, endIndex);
}
return pattern[dartx.matchAsPrefix](this, index) != null;
}
get [dartx.isEmpty]() {
- return this[dartx.length] == 0;
+ return this.length == 0;
}
[dartx.compareTo](other) {
- if (!(typeof other == 'string')) dart.throw(_js_helper.argumentErrorValue(other));
+ if (other == null) dart.throw(_js_helper.argumentErrorValue(other));
return dart.equals(this, other) ? 0 : this < other ? -1 : 1;
}
get [dartx.hashCode]() {
let hash = 0;
- for (let i = 0; i < dart.notNull(this[dartx.length]); i++) {
+ let length = this.length;
+ for (let i = 0; i < length; i++) {
hash = 536870911 & hash + this.charCodeAt(i);
hash = 536870911 & hash + ((524287 & hash) << 10);
hash = hash ^ hash >> 6;
...
}
[dartx._get](index) {
- if (!(typeof index == 'number')) dart.throw(_js_helper.diagnoseIndexError(this, index));
- if (dart.notNull(index) >= dart.notNull(this[dartx.length]) || dart.notNull(index) < 0) dart.throw(_js_helper.diagnoseIndexError(this, index));
+ if (index == null || index >= this.length || index < 0) {
+ dart.throw(_js_helper.diagnoseIndexError(this, index));
+ }
return this[index];
}
Committed: https://github.com/dart-lang/sdk/commit/a7645f817f775f34e13d1cc73bef078a487f5817
Patch Set 1 #
Total comments: 1
Created: 3 years, 6 months ago
(Patch set is too large to download)
Messages
Total messages: 7 (3 generated)
|