Don't copy Int8Arrays when passing them in as lists of bytes and don't

call from C to Dart to get the values either.

Just copying the values over as is will behave the same as it does
now and will be a lot faster.

R=sgjesse@google.com
BUG=

Review URL: https://codereview.chromium.org//11418004

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14951 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
ager@google.com 2012-11-15 11:03:02 +00:00
parent ffa06389eb
commit 7d834933c3
2 changed files with 5 additions and 2 deletions

View file

@ -1950,7 +1950,8 @@ DART_EXPORT Dart_Handle Dart_ListGetAsBytes(Dart_Handle list,
Isolate* isolate = Isolate::Current();
DARTSCOPE(isolate);
const Object& obj = Object::Handle(isolate, Api::UnwrapHandle(list));
if (obj.IsUint8Array() || obj.IsExternalUint8Array()) {
if (obj.IsUint8Array() || obj.IsExternalUint8Array() ||
obj.IsInt8Array() || obj.IsExternalInt8Array()) {
const ByteArray& byte_array = ByteArray::Cast(obj);
if (Utils::RangeCheck(offset, length, byte_array.Length())) {
ByteArray::Copy(native_array, byte_array, offset, length);

View file

@ -68,7 +68,9 @@ class _BufferAndOffset {
// benefit that it is faster to access from the C code as well.
_BufferAndOffset _ensureFastAndSerializableBuffer(
List buffer, int offset, int bytes) {
if (buffer is Uint8List || _BufferUtils._isBuiltinList(buffer)) {
if (buffer is Uint8List ||
buffer is Int8List ||
_BufferUtils._isBuiltinList(buffer)) {
return new _BufferAndOffset(buffer, offset);
}
var newBuffer = new Uint8List(bytes);