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

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

Issue 11369259: Add one-char string table for faster String.charAt to the VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: added characters 0x80..0xff Created 8 years, 1 month 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/vm/object.cc » ('j') | runtime/vm/snapshot_test.cc » ('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"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 return 0; 95 return 0;
96 } 96 }
97 } 97 }
98 98
99 99
100 DEFINE_NATIVE_ENTRY(String_charAt, 2) { 100 DEFINE_NATIVE_ENTRY(String_charAt, 2) {
101 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); 101 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0));
102 GET_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1)); 102 GET_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1));
103 uint32_t value = StringValueAt(receiver, index); 103 uint32_t value = StringValueAt(receiver, index);
104 ASSERT(value <= 0x10FFFF); 104 ASSERT(value <= 0x10FFFF);
105 return Symbols::New(&value, 1); 105 return Symbols::FromCharCode(value);
106 } 106 }
107 107
108 DEFINE_NATIVE_ENTRY(String_charCodeAt, 2) { 108 DEFINE_NATIVE_ENTRY(String_charCodeAt, 2) {
109 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); 109 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0));
110 GET_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1)); 110 GET_NATIVE_ARGUMENT(Integer, index, arguments->NativeArgAt(1));
111 111
112 int32_t value = StringValueAt(receiver, index); 112 int32_t value = StringValueAt(receiver, index);
113 ASSERT(value >= 0); 113 ASSERT(value >= 0);
114 ASSERT(value <= 0x10FFFF); 114 ASSERT(value <= 0x10FFFF);
115 return Smi::New(value); 115 return Smi::New(value);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (!elem.IsString()) { 151 if (!elem.IsString()) {
152 GrowableArray<const Object*> args; 152 GrowableArray<const Object*> args;
153 args.Add(&elem); 153 args.Add(&elem);
154 Exceptions::ThrowByType(Exceptions::kArgument, args); 154 Exceptions::ThrowByType(Exceptions::kArgument, args);
155 } 155 }
156 } 156 }
157 return String::ConcatAll(strings); 157 return String::ConcatAll(strings);
158 } 158 }
159 159
160 } // namespace dart 160 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/vm/object.cc » ('j') | runtime/vm/snapshot_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698