| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 5314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5325 bool String::IsTwoByteEqualTo(Vector<const uc16> str) { | 5325 bool String::IsTwoByteEqualTo(Vector<const uc16> str) { |
| 5326 int slen = length(); | 5326 int slen = length(); |
| 5327 if (str.length() != slen) return false; | 5327 if (str.length() != slen) return false; |
| 5328 for (int i = 0; i < slen; i++) { | 5328 for (int i = 0; i < slen; i++) { |
| 5329 if (Get(i) != str[i]) return false; | 5329 if (Get(i) != str[i]) return false; |
| 5330 } | 5330 } |
| 5331 return true; | 5331 return true; |
| 5332 } | 5332 } |
| 5333 | 5333 |
| 5334 | 5334 |
| 5335 template <typename schar> | |
| 5336 static inline uint32_t HashSequentialString(const schar* chars, int length) { | |
| 5337 StringHasher hasher(length); | |
| 5338 if (!hasher.has_trivial_hash()) { | |
| 5339 int i; | |
| 5340 for (i = 0; hasher.is_array_index() && (i < length); i++) { | |
| 5341 hasher.AddCharacter(chars[i]); | |
| 5342 } | |
| 5343 for (; i < length; i++) { | |
| 5344 hasher.AddCharacterNoIndex(chars[i]); | |
| 5345 } | |
| 5346 } | |
| 5347 return hasher.GetHashField(); | |
| 5348 } | |
| 5349 | |
| 5350 | |
| 5351 uint32_t String::ComputeAndSetHash() { | 5335 uint32_t String::ComputeAndSetHash() { |
| 5352 // Should only be called if hash code has not yet been computed. | 5336 // Should only be called if hash code has not yet been computed. |
| 5353 ASSERT(!HasHashCode()); | 5337 ASSERT(!HasHashCode()); |
| 5354 | 5338 |
| 5355 const int len = length(); | 5339 const int len = length(); |
| 5356 | 5340 |
| 5357 // Compute the hash code. | 5341 // Compute the hash code. |
| 5358 uint32_t field = 0; | 5342 uint32_t field = 0; |
| 5359 if (StringShape(this).IsSequentialAscii()) { | 5343 if (StringShape(this).IsSequentialAscii()) { |
| 5360 field = HashSequentialString(SeqAsciiString::cast(this)->GetChars(), len); | 5344 field = HashSequentialString(SeqAsciiString::cast(this)->GetChars(), len); |
| (...skipping 4800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10161 if (break_point_objects()->IsUndefined()) return 0; | 10145 if (break_point_objects()->IsUndefined()) return 0; |
| 10162 // Single beak point. | 10146 // Single beak point. |
| 10163 if (!break_point_objects()->IsFixedArray()) return 1; | 10147 if (!break_point_objects()->IsFixedArray()) return 1; |
| 10164 // Multiple break points. | 10148 // Multiple break points. |
| 10165 return FixedArray::cast(break_point_objects())->length(); | 10149 return FixedArray::cast(break_point_objects())->length(); |
| 10166 } | 10150 } |
| 10167 #endif | 10151 #endif |
| 10168 | 10152 |
| 10169 | 10153 |
| 10170 } } // namespace v8::internal | 10154 } } // namespace v8::internal |
| OLD | NEW |