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

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

Issue 47073009: Improve indexOf for one byte string receiver to work with other string classes. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 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/lib/string_patch.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) 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 GET_NON_NULL_NATIVE_ARGUMENT(String, receiver, arguments->NativeArgAt(0)); 127 GET_NON_NULL_NATIVE_ARGUMENT(String, receiver, arguments->NativeArgAt(0));
128 ASSERT(receiver.IsOneByteString()); 128 ASSERT(receiver.IsOneByteString());
129 GET_NON_NULL_NATIVE_ARGUMENT(Smi, index_obj, arguments->NativeArgAt(1)); 129 GET_NON_NULL_NATIVE_ARGUMENT(Smi, index_obj, arguments->NativeArgAt(1));
130 GET_NON_NULL_NATIVE_ARGUMENT(Smi, code_point_obj, arguments->NativeArgAt(2)); 130 GET_NON_NULL_NATIVE_ARGUMENT(Smi, code_point_obj, arguments->NativeArgAt(2));
131 ASSERT((0 <= code_point_obj.Value()) && (code_point_obj.Value() <= 0xFF)); 131 ASSERT((0 <= code_point_obj.Value()) && (code_point_obj.Value() <= 0xFF));
132 OneByteString::SetCharAt(receiver, index_obj.Value(), code_point_obj.Value()); 132 OneByteString::SetCharAt(receiver, index_obj.Value(), code_point_obj.Value());
133 return Object::null(); 133 return Object::null();
134 } 134 }
135 135
136 136
137 DEFINE_NATIVE_ENTRY(ExternalOneByteString_getCid, 0) {
138 return Smi::New(kExternalOneByteStringCid);
139 }
140
141
137 DEFINE_NATIVE_ENTRY(String_getHashCode, 1) { 142 DEFINE_NATIVE_ENTRY(String_getHashCode, 1) {
138 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); 143 const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0));
139 intptr_t hash_val = receiver.Hash(); 144 intptr_t hash_val = receiver.Hash();
140 ASSERT(hash_val > 0); 145 ASSERT(hash_val > 0);
141 ASSERT(Smi::IsValid(hash_val)); 146 ASSERT(Smi::IsValid(hash_val));
142 return Smi::New(hash_val); 147 return Smi::New(hash_val);
143 } 148 }
144 149
145 150
146 DEFINE_NATIVE_ENTRY(String_getLength, 1) { 151 DEFINE_NATIVE_ENTRY(String_getLength, 1) {
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) 266 ? String::Handle(OneByteString::New(length_value, Heap::kNew))
262 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); 267 : String::Handle(TwoByteString::New(length_value, Heap::kNew));
263 NoGCScope no_gc; 268 NoGCScope no_gc;
264 269
265 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0)); 270 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0));
266 String::Copy(result, 0, data_position, length_value); 271 String::Copy(result, 0, data_position, length_value);
267 return result.raw(); 272 return result.raw();
268 } 273 }
269 274
270 } // namespace dart 275 } // namespace dart
OLDNEW
« no previous file with comments | « no previous file | runtime/lib/string_patch.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698