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

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

Issue 368483004: Avoid unnecessary copying when parsing doubles. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Also use the native parse directly in JSON parsing. Created 6 years, 5 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
« runtime/lib/double_patch.dart ('K') | « runtime/vm/object.h ('k') | no next file » | 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 9419 matching lines...) Expand 10 before | Expand all | Expand 10 after
9430 set_index(libs.Length()); 9430 set_index(libs.Length());
9431 libs.Add(*this); 9431 libs.Add(*this);
9432 } 9432 }
9433 9433
9434 9434
9435 RawLibrary* Library::AsyncLibrary() { 9435 RawLibrary* Library::AsyncLibrary() {
9436 return Isolate::Current()->object_store()->async_library(); 9436 return Isolate::Current()->object_store()->async_library();
9437 } 9437 }
9438 9438
9439 9439
9440 RawLibrary* Library::ConvertLibrary() {
9441 return Isolate::Current()->object_store()->convert_library();
9442 }
9443
9444
9440 RawLibrary* Library::CoreLibrary() { 9445 RawLibrary* Library::CoreLibrary() {
9441 return Isolate::Current()->object_store()->core_library(); 9446 return Isolate::Current()->object_store()->core_library();
9442 } 9447 }
9443 9448
9444 9449
9445 RawLibrary* Library::CollectionLibrary() { 9450 RawLibrary* Library::CollectionLibrary() {
9446 return Isolate::Current()->object_store()->collection_library(); 9451 return Isolate::Current()->object_store()->collection_library();
9447 } 9452 }
9448 9453
9449 9454
(...skipping 7450 matching lines...) Expand 10 before | Expand all | Expand 10 after
16900 // TODO(cshapiro): create a fast-path for OneByteString instances. 16905 // TODO(cshapiro): create a fast-path for OneByteString instances.
16901 return Transform(CaseMapping::ToUpper, str, space); 16906 return Transform(CaseMapping::ToUpper, str, space);
16902 } 16907 }
16903 16908
16904 16909
16905 RawString* String::ToLowerCase(const String& str, Heap::Space space) { 16910 RawString* String::ToLowerCase(const String& str, Heap::Space space) {
16906 // TODO(cshapiro): create a fast-path for OneByteString instances. 16911 // TODO(cshapiro): create a fast-path for OneByteString instances.
16907 return Transform(CaseMapping::ToLower, str, space); 16912 return Transform(CaseMapping::ToLower, str, space);
16908 } 16913 }
16909 16914
16915 bool String::ParseDouble(const String& str,
16916 intptr_t start, intptr_t end,
16917 double* result) {
16918 ASSERT(0 <= start);
16919 ASSERT(start <= end);
16920 ASSERT(end <= str.Length());
16921 int length = end - start;
16922 NoGCScope no_gc;
16923 const uint8_t* startChar;
16924 if (str.IsOneByteString()) {
16925 startChar = OneByteString::CharAddr(str, start);
16926 } else if (str.IsExternalOneByteString()) {
16927 startChar = ExternalOneByteString::CharAddr(str, start);
16928 } else {
16929 uint8_t* chars = Isolate::Current()->current_zone()->Alloc<uint8_t>(length);
16930 for (int i = 0; i < length; i++) {
16931 int ch = str.CharAt(start + i);
16932 if (ch < 128) {
16933 chars[i] = ch;
16934 } else {
16935 return false; // Not ASCII, so definitely not valid double numeral.
16936 }
16937 }
16938 startChar = chars;
16939 }
16940 return CStringToDouble(reinterpret_cast<const char*>(startChar),
16941 length, result);
16942 }
16943
16910 16944
16911 // Check to see if 'str1' matches 'str2' as is or 16945 // Check to see if 'str1' matches 'str2' as is or
16912 // once the private key separator is stripped from str2. 16946 // once the private key separator is stripped from str2.
16913 // 16947 //
16914 // Things are made more complicated by the fact that constructors are 16948 // Things are made more complicated by the fact that constructors are
16915 // added *after* the private suffix, so "foo@123.named" should match 16949 // added *after* the private suffix, so "foo@123.named" should match
16916 // "foo.named". 16950 // "foo.named".
16917 // 16951 //
16918 // Also, the private suffix can occur more than once in the name, as in: 16952 // Also, the private suffix can occur more than once in the name, as in:
16919 // 16953 //
(...skipping 2072 matching lines...) Expand 10 before | Expand all | Expand 10 after
18992 return tag_label.ToCString(); 19026 return tag_label.ToCString();
18993 } 19027 }
18994 19028
18995 19029
18996 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const { 19030 void UserTag::PrintJSONImpl(JSONStream* stream, bool ref) const {
18997 Instance::PrintJSONImpl(stream, ref); 19031 Instance::PrintJSONImpl(stream, ref);
18998 } 19032 }
18999 19033
19000 19034
19001 } // namespace dart 19035 } // namespace dart
OLDNEW
« runtime/lib/double_patch.dart ('K') | « runtime/vm/object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698