Chromium Code Reviews| Index: runtime/bin/file.cc |
| diff --git a/runtime/bin/file.cc b/runtime/bin/file.cc |
| index e366fc23cda3069030abca5d0f6b1d028a7b0559..322f92804c4520ba1dc414bfd88a3f4005c0a253 100644 |
| --- a/runtime/bin/file.cc |
| +++ b/runtime/bin/file.cc |
| @@ -1,4 +1,4 @@ |
| -// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
|
Ivan Posva
2013/02/27 18:18:56
No need to update.
|
| // 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. |
| @@ -180,12 +180,25 @@ void FUNCTION_NAME(File_Read)(Dart_NativeArguments args) { |
| Dart_SetReturnValue(args, err); |
| } else { |
| if (bytes_read < length) { |
| - // TODO(ager): cache the 'length' string if this becomes a bottle neck. |
| - Dart_SetField(external_array, |
|
Mads Ager (google)
2013/02/27 15:02:36
I should have been beaten with a stick for doing t
|
| - DartUtils::NewString("length"), |
| - Dart_NewInteger(bytes_read)); |
| + const int kNumArgs = 3; |
| + Dart_Handle dart_args[kNumArgs]; |
| + dart_args[0] = external_array; |
| + dart_args[1] = Dart_NewInteger(0); |
| + dart_args[2] = Dart_NewInteger(bytes_read); |
| + // TODO(sgjesse): Cache the _makeUint8ListView function somewhere. |
| + Dart_Handle io_lib = |
| + Dart_LookupLibrary(DartUtils::NewString("dart:io")); |
| + if (Dart_IsError(io_lib)) Dart_PropagateError(io_lib); |
| + Dart_Handle array_view = |
| + Dart_Invoke(io_lib, |
| + DartUtils::NewString("_makeUint8ListView"), |
| + kNumArgs, |
| + dart_args); |
| + if (Dart_IsError(array_view)) Dart_PropagateError(array_view); |
| + Dart_SetReturnValue(args, array_view); |
| + } else { |
| + Dart_SetReturnValue(args, external_array); |
| } |
| - Dart_SetReturnValue(args, external_array); |
| } |
| } else { |
| OSError os_error(-1, "Invalid argument", OSError::kUnknown); |