Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 5656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5667 if (V8_LIKELY(I::IsValidSmi(i))) { | 5667 if (V8_LIKELY(I::IsValidSmi(i))) { |
| 5668 *value_ = I::IntToSmi(i); | 5668 *value_ = I::IntToSmi(i); |
| 5669 return; | 5669 return; |
| 5670 } | 5670 } |
| 5671 Set(Integer::New(i, GetIsolate())); | 5671 Set(Integer::New(i, GetIsolate())); |
| 5672 } | 5672 } |
| 5673 | 5673 |
| 5674 template<typename T> | 5674 template<typename T> |
| 5675 void ReturnValue<T>::Set(uint32_t i) { | 5675 void ReturnValue<T>::Set(uint32_t i) { |
| 5676 typedef internal::Internals I; | 5676 typedef internal::Internals I; |
| 5677 if (V8_LIKELY(I::IsValidSmi(i))) { | 5677 bool fits_into_int32_t = (i & (1 << 31)) == 0; |
|
Sven Panne
2013/06/07 07:05:06
I think 'i < INT32_MAX' is more readable than this
| |
| 5678 *value_ = I::IntToSmi(i); | 5678 if (V8_LIKELY(fits_into_int32_t)) { |
| 5679 Set(static_cast<int32_t>(i)); | |
| 5679 return; | 5680 return; |
| 5680 } | 5681 } |
| 5681 Set(Integer::NewFromUnsigned(i, GetIsolate())); | 5682 Set(Integer::NewFromUnsigned(i, GetIsolate())); |
| 5682 } | 5683 } |
| 5683 | 5684 |
| 5684 template<typename T> | 5685 template<typename T> |
| 5685 void ReturnValue<T>::Set(bool value) { | 5686 void ReturnValue<T>::Set(bool value) { |
| 5686 typedef internal::Internals I; | 5687 typedef internal::Internals I; |
| 5687 int root_index; | 5688 int root_index; |
| 5688 if (value) { | 5689 if (value) { |
| (...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6284 | 6285 |
| 6285 | 6286 |
| 6286 } // namespace v8 | 6287 } // namespace v8 |
| 6287 | 6288 |
| 6288 | 6289 |
| 6289 #undef V8EXPORT | 6290 #undef V8EXPORT |
| 6290 #undef TYPE_CHECK | 6291 #undef TYPE_CHECK |
| 6291 | 6292 |
| 6292 | 6293 |
| 6293 #endif // V8_H_ | 6294 #endif // V8_H_ |
| OLD | NEW |