| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 2178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2189 is_first_char_(true), | 2189 is_first_char_(true), |
| 2190 is_valid_(true) { } | 2190 is_valid_(true) { } |
| 2191 | 2191 |
| 2192 | 2192 |
| 2193 bool StringHasher::has_trivial_hash() { | 2193 bool StringHasher::has_trivial_hash() { |
| 2194 return length_ > String::kMaxMediumStringSize; | 2194 return length_ > String::kMaxMediumStringSize; |
| 2195 } | 2195 } |
| 2196 | 2196 |
| 2197 | 2197 |
| 2198 void StringHasher::AddCharacter(uc32 c) { | 2198 void StringHasher::AddCharacter(uc32 c) { |
| 2199 // Note: the Jenkins one-at-a-time hash function | 2199 // Use the Jenkins one-at-a-time hash function to update the hash |
| 2200 // for the given character. |
| 2200 raw_running_hash_ += c; | 2201 raw_running_hash_ += c; |
| 2201 raw_running_hash_ += (raw_running_hash_ << 10); | 2202 raw_running_hash_ += (raw_running_hash_ << 10); |
| 2202 raw_running_hash_ ^= (raw_running_hash_ >> 6); | 2203 raw_running_hash_ ^= (raw_running_hash_ >> 6); |
| 2203 // Incremental array index computation | 2204 // Incremental array index computation. |
| 2204 if (is_array_index_) { | 2205 if (is_array_index_) { |
| 2205 if (c < '0' || c > '9') { | 2206 if (c < '0' || c > '9') { |
| 2206 is_array_index_ = false; | 2207 is_array_index_ = false; |
| 2207 } else { | 2208 } else { |
| 2208 int d = c - '0'; | 2209 int d = c - '0'; |
| 2209 if (is_first_char_) { | 2210 if (is_first_char_) { |
| 2210 is_first_char_ = false; | 2211 is_first_char_ = false; |
| 2211 if (c == '0' && length_ > 1) { | 2212 if (c == '0' && length_ > 1) { |
| 2212 is_array_index_ = false; | 2213 is_array_index_ = false; |
| 2213 return; | 2214 return; |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2343 #undef WRITE_INT_FIELD | 2344 #undef WRITE_INT_FIELD |
| 2344 #undef READ_SHORT_FIELD | 2345 #undef READ_SHORT_FIELD |
| 2345 #undef WRITE_SHORT_FIELD | 2346 #undef WRITE_SHORT_FIELD |
| 2346 #undef READ_BYTE_FIELD | 2347 #undef READ_BYTE_FIELD |
| 2347 #undef WRITE_BYTE_FIELD | 2348 #undef WRITE_BYTE_FIELD |
| 2348 | 2349 |
| 2349 | 2350 |
| 2350 } } // namespace v8::internal | 2351 } } // namespace v8::internal |
| 2351 | 2352 |
| 2352 #endif // V8_OBJECTS_INL_H_ | 2353 #endif // V8_OBJECTS_INL_H_ |
| OLD | NEW |