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

Unified 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, 11 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 | « runtime/vm/object.h ('k') | sdk/lib/core/errors.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/object.cc
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 4a7eb4914efb1b16e1b73c876a13889f6ae9712a..5030d55456a6ffea0d399cc7d3d0f8cab23a3fc3 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -18665,6 +18665,36 @@ RawTwoByteString* TwoByteString::New(const String& str,
}
+RawTwoByteString* TwoByteString::New(const TypedData& other_typed_data,
+ intptr_t other_start_index,
+ intptr_t other_len,
+ Heap::Space space) {
+ const String& result = String::Handle(TwoByteString::New(other_len, space));
+ if (other_len > 0) {
+ NoGCScope no_gc;
+ memmove(TwoByteString::CharAddr(result, 0),
+ other_typed_data.DataAddr(other_start_index),
+ other_len * sizeof(uint16_t));
+ }
+ return TwoByteString::raw(result);
+}
+
+
+RawTwoByteString* TwoByteString::New(const ExternalTypedData& other_typed_data,
+ intptr_t other_start_index,
+ intptr_t other_len,
+ Heap::Space space) {
+ const String& result = String::Handle(TwoByteString::New(other_len, space));
+ if (other_len > 0) {
+ NoGCScope no_gc;
+ memmove(TwoByteString::CharAddr(result, 0),
+ other_typed_data.DataAddr(other_start_index),
+ other_len * sizeof(uint16_t));
+ }
+ return TwoByteString::raw(result);
+}
+
+
RawTwoByteString* TwoByteString::Concat(const String& str1,
const String& str2,
Heap::Space space) {
« 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