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

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: 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..df06206e64fb41b55a4ddd10f182322a2342c6fd 100644
--- a/runtime/lib/string.cc
+++ b/runtime/lib/string.cc
@@ -13,10 +13,21 @@
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));
+ bool is_growable = list.IsGrowableObjectArray();
+ if (!is_growable && !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(
+ is_growable ? GrowableObjectArray::Cast(list).data()
+ : Array::Cast(list).raw());
+ intptr_t array_len = is_growable ? GrowableObjectArray::Cast(list).Length()
+ : a.Length();
siva 2013/03/14 15:56:02 I would structure this code as: if (!list.IsGrowab
Lasse Reichstein Nielsen 2013/03/15 06:58:40 Much better. Done!
+
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;
@@ -49,7 +60,6 @@ DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) {
return TwoByteString::New(utf16_len, utf32_array, array_len, Heap::kNew);
}
siva 2013/03/14 15:56:02 Why remove the blank line here, we normally have 2
Lasse Reichstein Nielsen 2013/03/15 06:58:40 No reason. I moved the body of the method into a h
-
DEFINE_NATIVE_ENTRY(StringBase_substringUnchecked, 3) {
const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0));
GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_obj, arguments->NativeArgAt(1));
« 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