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

Side by Side Diff: runtime/vm/object.cc

Issue 864463002: Create string efficiently from Uint16List/View. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests for external typed-data Created 5 years, 10 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 | « runtime/vm/object.h ('k') | sdk/lib/core/errors.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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/object.h" 5 #include "vm/object.h"
6 6
7 #include "include/dart_api.h" 7 #include "include/dart_api.h"
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/assembler.h" 9 #include "vm/assembler.h"
10 #include "vm/cpu.h" 10 #include "vm/cpu.h"
(...skipping 18647 matching lines...) Expand 10 before | Expand all | Expand 10 after
18658 18658
18659 RawTwoByteString* TwoByteString::New(const String& str, 18659 RawTwoByteString* TwoByteString::New(const String& str,
18660 Heap::Space space) { 18660 Heap::Space space) {
18661 intptr_t len = str.Length(); 18661 intptr_t len = str.Length();
18662 const String& result = String::Handle(TwoByteString::New(len, space)); 18662 const String& result = String::Handle(TwoByteString::New(len, space));
18663 String::Copy(result, 0, str, 0, len); 18663 String::Copy(result, 0, str, 0, len);
18664 return TwoByteString::raw(result); 18664 return TwoByteString::raw(result);
18665 } 18665 }
18666 18666
18667 18667
18668 RawTwoByteString* TwoByteString::New(const TypedData& other_typed_data,
18669 intptr_t other_start_index,
18670 intptr_t other_len,
18671 Heap::Space space) {
18672 const String& result = String::Handle(TwoByteString::New(other_len, space));
18673 if (other_len > 0) {
18674 NoGCScope no_gc;
18675 memmove(TwoByteString::CharAddr(result, 0),
18676 other_typed_data.DataAddr(other_start_index),
18677 other_len * sizeof(uint16_t));
18678 }
18679 return TwoByteString::raw(result);
18680 }
18681
18682
18683 RawTwoByteString* TwoByteString::New(const ExternalTypedData& other_typed_data,
18684 intptr_t other_start_index,
18685 intptr_t other_len,
18686 Heap::Space space) {
18687 const String& result = String::Handle(TwoByteString::New(other_len, space));
18688 if (other_len > 0) {
18689 NoGCScope no_gc;
18690 memmove(TwoByteString::CharAddr(result, 0),
18691 other_typed_data.DataAddr(other_start_index),
18692 other_len * sizeof(uint16_t));
18693 }
18694 return TwoByteString::raw(result);
18695 }
18696
18697
18668 RawTwoByteString* TwoByteString::Concat(const String& str1, 18698 RawTwoByteString* TwoByteString::Concat(const String& str1,
18669 const String& str2, 18699 const String& str2,
18670 Heap::Space space) { 18700 Heap::Space space) {
18671 intptr_t len1 = str1.Length(); 18701 intptr_t len1 = str1.Length();
18672 intptr_t len2 = str2.Length(); 18702 intptr_t len2 = str2.Length();
18673 intptr_t len = len1 + len2; 18703 intptr_t len = len1 + len2;
18674 const String& result = String::Handle(TwoByteString::New(len, space)); 18704 const String& result = String::Handle(TwoByteString::New(len, space));
18675 String::Copy(result, 0, str1, 0, len1); 18705 String::Copy(result, 0, str1, 0, len1);
18676 String::Copy(result, len1, str2, 0, len2); 18706 String::Copy(result, len1, str2, 0, len2);
18677 return TwoByteString::raw(result); 18707 return TwoByteString::raw(result);
(...skipping 1852 matching lines...) Expand 10 before | Expand all | Expand 10 after
20530 return tag_label.ToCString(); 20560 return tag_label.ToCString();
20531 } 20561 }
20532 20562
20533 20563
20534 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 20564 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
20535 Instance::PrintJSONImpl(stream, ref); 20565 Instance::PrintJSONImpl(stream, ref);
20536 } 20566 }
20537 20567
20538 20568
20539 } // namespace dart 20569 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/object.h ('k') | sdk/lib/core/errors.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698