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

Side by Side Diff: runtime/lib/string.cc

Issue 14868002: Do not copy immutable arrays in String.createFromCharCodes. Tighten the types a little in string_pa… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | runtime/lib/string_patch.dart » ('j') | runtime/lib/string_patch.dart » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/bootstrap_natives.h" 5 #include "vm/bootstrap_natives.h"
6 6
7 #include "vm/exceptions.h" 7 #include "vm/exceptions.h"
8 #include "vm/native_entry.h" 8 #include "vm/native_entry.h"
9 #include "vm/object.h" 9 #include "vm/object.h"
10 #include "vm/symbols.h" 10 #include "vm/symbols.h"
11 #include "vm/unicode.h" 11 #include "vm/unicode.h"
12 12
13 namespace dart { 13 namespace dart {
14 14
15 DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) { 15 DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) {
16 GET_NON_NULL_NATIVE_ARGUMENT(Instance, list, arguments->NativeArgAt(0)); 16 GET_NON_NULL_NATIVE_ARGUMENT(Instance, list, arguments->NativeArgAt(0));
17 if (!list.IsGrowableObjectArray() && !list.IsArray()) { 17 if (!list.IsGrowableObjectArray() && !list.IsArray()) {
18 const Array& args = Array::Handle(Array::New(1)); 18 const Array& args = Array::Handle(Array::New(1));
19 args.SetAt(0, list); 19 args.SetAt(0, list);
20 Exceptions::ThrowByType(Exceptions::kArgument, args); 20 Exceptions::ThrowByType(Exceptions::kArgument, args);
21 } 21 }
22 // TODO(srdjan): Check that parameterized type is an int.
23 22
24 Array& a = Array::Handle(); 23 Array& a = Array::Handle();
25 intptr_t array_len; 24 intptr_t array_len;
26 if (list.IsGrowableObjectArray()) { 25 if (list.IsGrowableObjectArray()) {
27 const GrowableObjectArray& growableArray = GrowableObjectArray::Cast(list); 26 const GrowableObjectArray& growableArray = GrowableObjectArray::Cast(list);
28 a ^= growableArray.data(); 27 a ^= growableArray.data();
29 array_len = growableArray.Length(); 28 array_len = growableArray.Length();
30 } else { 29 } else {
31 a ^= Array::Cast(list).raw(); 30 a ^= Array::Cast(list).raw();
32 array_len = a.Length(); 31 array_len = a.Length();
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) 228 ? String::Handle(OneByteString::New(length_value, Heap::kNew))
230 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); 229 : String::Handle(TwoByteString::New(length_value, Heap::kNew));
231 NoGCScope no_gc; 230 NoGCScope no_gc;
232 231
233 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0)); 232 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0));
234 String::Copy(result, 0, data_position, length_value); 233 String::Copy(result, 0, data_position, length_value);
235 return result.raw(); 234 return result.raw();
236 } 235 }
237 236
238 } // namespace dart 237 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/string_patch.dart » ('j') | runtime/lib/string_patch.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698