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

Unified Diff: runtime/lib/typed_data.dart

Issue 189443004: Fix performance of setRange by avoiding going to Lists.copy (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 9 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 | « runtime/lib/typed_data.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/typed_data.dart
===================================================================
--- runtime/lib/typed_data.dart (revision 33497)
+++ runtime/lib/typed_data.dart (working copy)
@@ -56,8 +56,6 @@
int length]) {
return new _Uint8ClampedArrayView(buffer, offsetInBytes, length);
}
-
- bool _isClamped() { return true; }
}
@@ -528,8 +526,6 @@
return IterableMixinWorkaround.getRangeList(this, start, end);
}
- bool _isClamped() { return false; }
-
void setRange(int start, int end, Iterable from, [int skipCount = 0]) {
// Check ranges.
if ((start < 0) || (start > length)) {
@@ -551,18 +547,14 @@
}
if (from is _TypedListBase) {
- final needsClamping =
- this._isClamped() && (this._isClamped() != from._isClamped());
if (this.elementSizeInBytes == from.elementSizeInBytes) {
- if (needsClamping) {
- Lists.copy(from, skipCount, this, start, count);
+ if (this.buffer._setRange(
+ start * elementSizeInBytes + this.offsetInBytes,
+ count * elementSizeInBytes,
+ from.buffer,
+ skipCount * elementSizeInBytes + from.offsetInBytes,
+ this._cid, from._cid)) {
return;
- } else if (this.buffer._setRange(
- start * elementSizeInBytes + this.offsetInBytes,
- count * elementSizeInBytes,
- from.buffer,
- skipCount * elementSizeInBytes + from.offsetInBytes)) {
- return;
}
} else if (from.buffer == this.buffer) {
// Different element sizes, but same buffer means that we need
@@ -602,11 +594,16 @@
// Internal utility methods.
// Returns true if operation succeeds.
- // Returns false if 'from' and 'this' do not have the same element types.
- // The copy occurs using a memory copy (no clamping, conversion, etc).
+ // 'fromCid' and 'toCid' may be cid-s of the views and therefore may not
+ // match the cids of 'this' and 'from'.
+ // Uses toCid and fromCid to decide if clamping is necessary.
+ // Element size of toCid and fromCid must match (test at caller).
bool _setRange(int startInBytes, int lengthInBytes,
- _TypedListBase from, int startFromInBytes)
+ _TypedListBase from, int startFromInBytes,
+ int toCid, int fromCid)
native "TypedData_setRange";
+
+ int get _cid native "Object_cid";
}
@@ -797,8 +794,6 @@
return new _Uint8ClampedArrayView(buffer, offsetInBytes, length);
}
- bool _isClamped() { return true; }
-
// Methods implementing List interface.
int operator[](int index) {
@@ -1624,8 +1619,6 @@
return _new(length);
}
- bool _isClamped() { return true; }
-
// Method(s) implementing the List interface.
int operator[](int index) {
@@ -2660,8 +2653,6 @@
}
- bool _isClamped() { return true; }
-
// Method(s) implementing List interface.
int operator[](int index) {
« no previous file with comments | « runtime/lib/typed_data.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698