OLD | NEW |
1 // Copyright 2007-2010 the V8 project authors. All rights reserved. | 1 // Copyright 2007-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 12 matching lines...) Expand all Loading... |
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | 27 |
28 #ifndef V8_UNICODE_INL_H_ | 28 #ifndef V8_UNICODE_INL_H_ |
29 #define V8_UNICODE_INL_H_ | 29 #define V8_UNICODE_INL_H_ |
30 | 30 |
31 #include "unicode.h" | 31 #include "unicode.h" |
32 #include "checks.h" | 32 #include "checks.h" |
| 33 #include "platform.h" |
33 | 34 |
34 namespace unibrow { | 35 namespace unibrow { |
35 | 36 |
36 template <class T, int s> bool Predicate<T, s>::get(uchar code_point) { | 37 template <class T, int s> bool Predicate<T, s>::get(uchar code_point) { |
37 CacheEntry entry = entries_[code_point & kMask]; | 38 CacheEntry entry = entries_[code_point & kMask]; |
38 if (entry.code_point_ == code_point) return entry.value_; | 39 if (entry.code_point_ == code_point) return entry.value_; |
39 return CalculateValue(code_point); | 40 return CalculateValue(code_point); |
40 } | 41 } |
41 | 42 |
42 template <class T, int s> bool Predicate<T, s>::CalculateValue( | 43 template <class T, int s> bool Predicate<T, s>::CalculateValue( |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 | 196 |
196 template <unsigned kBufferSize> | 197 template <unsigned kBufferSize> |
197 unsigned Utf8Decoder<kBufferSize>::WriteUtf16(uint16_t* data, | 198 unsigned Utf8Decoder<kBufferSize>::WriteUtf16(uint16_t* data, |
198 unsigned length) const { | 199 unsigned length) const { |
199 ASSERT(length > 0); | 200 ASSERT(length > 0); |
200 if (length > utf16_length_) length = utf16_length_; | 201 if (length > utf16_length_) length = utf16_length_; |
201 // memcpy everything in buffer. | 202 // memcpy everything in buffer. |
202 unsigned buffer_length = | 203 unsigned buffer_length = |
203 last_byte_of_buffer_unused_ ? kBufferSize - 1 : kBufferSize; | 204 last_byte_of_buffer_unused_ ? kBufferSize - 1 : kBufferSize; |
204 unsigned memcpy_length = length <= buffer_length ? length : buffer_length; | 205 unsigned memcpy_length = length <= buffer_length ? length : buffer_length; |
205 memcpy(data, buffer_, memcpy_length*sizeof(uint16_t)); | 206 v8::internal::OS::MemCopy(data, buffer_, memcpy_length*sizeof(uint16_t)); |
206 if (length <= buffer_length) return length; | 207 if (length <= buffer_length) return length; |
207 ASSERT(unbuffered_start_ != NULL); | 208 ASSERT(unbuffered_start_ != NULL); |
208 // Copy the rest the slow way. | 209 // Copy the rest the slow way. |
209 WriteUtf16Slow(unbuffered_start_, | 210 WriteUtf16Slow(unbuffered_start_, |
210 data + buffer_length, | 211 data + buffer_length, |
211 length - buffer_length); | 212 length - buffer_length); |
212 return length; | 213 return length; |
213 } | 214 } |
214 | 215 |
215 } // namespace unibrow | 216 } // namespace unibrow |
216 | 217 |
217 #endif // V8_UNICODE_INL_H_ | 218 #endif // V8_UNICODE_INL_H_ |
OLD | NEW |