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

Unified Diff: runtime/lib/string.cc

Issue 12632014: Allow String.fromCharCodes to work directly on a GrowableObjectArray. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed review comments. Created 7 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 | « no previous file | runtime/lib/string_base.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/string.cc
diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc
index 48b81e96fb72e94bebc075241071b3fb7dc97098..c282b7a5f47b367d163da8758b6e1661fded037b 100644
--- a/runtime/lib/string.cc
+++ b/runtime/lib/string.cc
@@ -13,10 +13,26 @@
namespace dart {
DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) {
- GET_NON_NULL_NATIVE_ARGUMENT(Array, a, arguments->NativeArgAt(0));
+ GET_NON_NULL_NATIVE_ARGUMENT(Instance, list, arguments->NativeArgAt(0));
+ if (!list.IsGrowableObjectArray() && !list.IsArray()) {
+ const Array& args = Array::Handle(Array::New(1));
+ args.SetAt(0, list);
+ Exceptions::ThrowByType(Exceptions::kArgument, args);
+ }
// TODO(srdjan): Check that parameterized type is an int.
+
+ Array& a = Array::Handle();
+ intptr_t array_len;
+ if (list.IsGrowableObjectArray()) {
+ const GrowableObjectArray& growableArray = GrowableObjectArray::Cast(list);
+ a ^= growableArray.data();
+ array_len = growableArray.Length();
+ } else {
+ a ^= Array::Cast(list).raw();
+ array_len = a.Length();
+ }
+
Zone* zone = isolate->current_zone();
- intptr_t array_len = a.Length();
// Unbox the array and determine the maximum element width.
bool is_one_byte_string = true;
« no previous file with comments | « no previous file | runtime/lib/string_base.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698