Chromium Code Reviews| Index: src/api.cc |
| =================================================================== |
| --- src/api.cc (revision 1810) |
| +++ src/api.cc (working copy) |
| @@ -2072,7 +2072,12 @@ |
| if (hash->IsSmi()) { |
| hash_value = i::Smi::cast(*hash)->value(); |
| } else { |
| - hash_value = random() & i::Smi::kMaxValue; // Limit range to fit a smi. |
| + int attempts = 0; |
| + do { |
| + hash_value = random() & i::Smi::kMaxValue; // Limit range to fit a smi. |
|
Dean McNamee
2009/04/29 09:14:52
Just to be annoying, we probably shouldn't be usin
|
| + attempts++; |
| + } while (hash_value == 0 && attempts < 30); |
| + hash_value = hash_value != 0 ? hash_value : 1; // never return 0 |
| i::SetProperty(hidden_props, |
| hash_symbol, |
| i::Handle<i::Object>(i::Smi::FromInt(hash_value)), |