| OLD | NEW |
| 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 20032 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20043 if (begin_index >= str.Length()) { | 20043 if (begin_index >= str.Length()) { |
| 20044 return String::null(); | 20044 return String::null(); |
| 20045 } | 20045 } |
| 20046 return String::SubString(str, | 20046 return String::SubString(str, |
| 20047 begin_index, | 20047 begin_index, |
| 20048 (str.Length() - begin_index), | 20048 (str.Length() - begin_index), |
| 20049 space); | 20049 space); |
| 20050 } | 20050 } |
| 20051 | 20051 |
| 20052 | 20052 |
| 20053 RawString* String::SubString(const String& str, | 20053 RawString* String::SubString(Thread* thread, |
| 20054 const String& str, |
| 20054 intptr_t begin_index, | 20055 intptr_t begin_index, |
| 20055 intptr_t length, | 20056 intptr_t length, |
| 20056 Heap::Space space) { | 20057 Heap::Space space) { |
| 20057 ASSERT(!str.IsNull()); | 20058 ASSERT(!str.IsNull()); |
| 20058 ASSERT(begin_index >= 0); | 20059 ASSERT(begin_index >= 0); |
| 20059 ASSERT(length >= 0); | 20060 ASSERT(length >= 0); |
| 20060 if (begin_index <= str.Length() && length == 0) { | 20061 if (begin_index <= str.Length() && length == 0) { |
| 20061 return Symbols::Empty().raw(); | 20062 return Symbols::Empty().raw(); |
| 20062 } | 20063 } |
| 20063 if (begin_index > str.Length()) { | 20064 if (begin_index > str.Length()) { |
| 20064 return String::null(); | 20065 return String::null(); |
| 20065 } | 20066 } |
| 20066 String& result = String::Handle(); | |
| 20067 bool is_one_byte_string = true; | 20067 bool is_one_byte_string = true; |
| 20068 intptr_t char_size = str.CharSize(); | 20068 intptr_t char_size = str.CharSize(); |
| 20069 if (char_size == kTwoByteChar) { | 20069 if (char_size == kTwoByteChar) { |
| 20070 for (intptr_t i = begin_index; i < begin_index + length; ++i) { | 20070 for (intptr_t i = begin_index; i < begin_index + length; ++i) { |
| 20071 if (!Utf::IsLatin1(str.CharAt(i))) { | 20071 if (!Utf::IsLatin1(str.CharAt(i))) { |
| 20072 is_one_byte_string = false; | 20072 is_one_byte_string = false; |
| 20073 break; | 20073 break; |
| 20074 } | 20074 } |
| 20075 } | 20075 } |
| 20076 } | 20076 } |
| 20077 REUSABLE_STRING_HANDLESCOPE(thread); |
| 20078 String& result = thread->StringHandle(); |
| 20077 if (is_one_byte_string) { | 20079 if (is_one_byte_string) { |
| 20078 result = OneByteString::New(length, space); | 20080 result = OneByteString::New(length, space); |
| 20079 } else { | 20081 } else { |
| 20080 result = TwoByteString::New(length, space); | 20082 result = TwoByteString::New(length, space); |
| 20081 } | 20083 } |
| 20082 String::Copy(result, 0, str, begin_index, length); | 20084 String::Copy(result, 0, str, begin_index, length); |
| 20083 return result.raw(); | 20085 return result.raw(); |
| 20084 } | 20086 } |
| 20085 | 20087 |
| 20086 | 20088 |
| (...skipping 2317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 22404 return UserTag::null(); | 22406 return UserTag::null(); |
| 22405 } | 22407 } |
| 22406 | 22408 |
| 22407 | 22409 |
| 22408 const char* UserTag::ToCString() const { | 22410 const char* UserTag::ToCString() const { |
| 22409 const String& tag_label = String::Handle(label()); | 22411 const String& tag_label = String::Handle(label()); |
| 22410 return tag_label.ToCString(); | 22412 return tag_label.ToCString(); |
| 22411 } | 22413 } |
| 22412 | 22414 |
| 22413 } // namespace dart | 22415 } // namespace dart |
| OLD | NEW |