Chromium Code Reviews| 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/become.h" | 10 #include "vm/become.h" |
| (...skipping 20079 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 20090 for (intptr_t i = 0; i < len; i++) { | 20090 for (intptr_t i = 0; i < len; i++) { |
| 20091 if (this->CharAt(i) != utf16_array[i]) { | 20091 if (this->CharAt(i) != utf16_array[i]) { |
| 20092 return false; | 20092 return false; |
| 20093 } | 20093 } |
| 20094 } | 20094 } |
| 20095 return true; | 20095 return true; |
| 20096 } | 20096 } |
| 20097 | 20097 |
| 20098 | 20098 |
| 20099 bool String::Equals(const int32_t* utf32_array, intptr_t len) const { | 20099 bool String::Equals(const int32_t* utf32_array, intptr_t len) const { |
| 20100 CodePointIterator it(*this); | 20100 if (len < 0) return false; |
| 20101 intptr_t i = 0; | 20101 intptr_t j = 0; |
| 20102 bool has_more = it.Next(); | 20102 for (intptr_t i = 0; i < len; ++i) { |
| 20103 while (has_more && (i < len)) { | 20103 if (Utf::IsSupplementary(utf32_array[i])) { |
| 20104 if ((it.Current() != static_cast<int32_t>(utf32_array[i]))) { | 20104 uint16_t encoded[2]; |
| 20105 return false; | 20105 Utf16::Encode(utf32_array[i], &encoded[0]); |
| 20106 if (j + 1 >= Length()) return false; | |
|
siva
2016/10/06 23:37:23
((j + 1) >= ... to maintain our style.
| |
| 20107 if (CharAt(j++) != encoded[0]) return false; | |
| 20108 if (CharAt(j++) != encoded[1]) return false; | |
| 20109 } else { | |
| 20110 if (j >= Length()) return false; | |
| 20111 if (CharAt(j++) != utf32_array[i]) return false; | |
| 20106 } | 20112 } |
| 20107 // Advance both streams forward. | |
| 20108 ++i; | |
| 20109 has_more = it.Next(); | |
| 20110 } | 20113 } |
| 20111 // Strings are only true iff we reached the end in both streams. | 20114 return j == Length(); |
|
siva
2016/10/06 23:37:23
The compiler maybe doing this optimization but I w
| |
| 20112 return (i == len) && !has_more; | |
| 20113 } | 20115 } |
| 20114 | 20116 |
| 20115 | 20117 |
| 20116 bool String::EqualsConcat(const String& str1, const String& str2) const { | 20118 bool String::EqualsConcat(const String& str1, const String& str2) const { |
| 20117 return (Length() == str1.Length() + str2.Length()) && | 20119 return (Length() == str1.Length() + str2.Length()) && |
| 20118 str1.Equals(*this, 0, str1.Length()) && | 20120 str1.Equals(*this, 0, str1.Length()) && |
| 20119 str2.Equals(*this, str1.Length(), str2.Length()); | 20121 str2.Equals(*this, str1.Length(), str2.Length()); |
| 20120 } | 20122 } |
| 20121 | 20123 |
| 20122 | 20124 |
| (...skipping 2880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 23003 return UserTag::null(); | 23005 return UserTag::null(); |
| 23004 } | 23006 } |
| 23005 | 23007 |
| 23006 | 23008 |
| 23007 const char* UserTag::ToCString() const { | 23009 const char* UserTag::ToCString() const { |
| 23008 const String& tag_label = String::Handle(label()); | 23010 const String& tag_label = String::Handle(label()); |
| 23009 return tag_label.ToCString(); | 23011 return tag_label.ToCString(); |
| 23010 } | 23012 } |
| 23011 | 23013 |
| 23012 } // namespace dart | 23014 } // namespace dart |
| OLD | NEW |