| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_UNIBROW_INL_H_ | 5 #ifndef VM_UNIBROW_INL_H_ |
| 6 #define VM_UNIBROW_INL_H_ | 6 #define VM_UNIBROW_INL_H_ |
| 7 | 7 |
| 8 #include "vm/unibrow.h" | 8 #include "vm/unibrow.h" |
| 9 | 9 |
| 10 // SNIP | 10 #include "platform/assert.h" |
| 11 | 11 |
| 12 namespace unibrow { | 12 namespace unibrow { |
| 13 | 13 |
| 14 // SNIP | 14 template <class T, intptr_t s> intptr_t Mapping<T, s>::get( |
| 15 | 15 int32_t c, int32_t n, int32_t* result) { |
| 16 template <class T, int s> int Mapping<T, s>::get(uchar c, uchar n, | |
| 17 uchar* result) { | |
| 18 CacheEntry entry = entries_[c & kMask]; | 16 CacheEntry entry = entries_[c & kMask]; |
| 19 if (entry.code_point_ == c) { | 17 if (entry.code_point_ == c) { |
| 20 if (entry.offset_ == 0) { | 18 if (entry.offset_ == 0) { |
| 21 return 0; | 19 return 0; |
| 22 } else { | 20 } else { |
| 23 result[0] = c + entry.offset_; | 21 result[0] = c + entry.offset_; |
| 24 return 1; | 22 return 1; |
| 25 } | 23 } |
| 26 } else { | 24 } else { |
| 27 return CalculateValue(c, n, result); | 25 return CalculateValue(c, n, result); |
| 28 } | 26 } |
| 29 } | 27 } |
| 30 | 28 |
| 31 template <class T, int s> int Mapping<T, s>::CalculateValue(uchar c, uchar n, | 29 template <class T, intptr_t s> intptr_t Mapping<T, s>::CalculateValue( |
| 32 uchar* result) { | 30 int32_t c, int32_t n, int32_t* result) { |
| 33 bool allow_caching = true; | 31 bool allow_caching = true; |
| 34 int length = T::Convert(c, n, result, &allow_caching); | 32 intptr_t length = T::Convert(c, n, result, &allow_caching); |
| 35 if (allow_caching) { | 33 if (allow_caching) { |
| 36 if (length == 1) { | 34 if (length == 1) { |
| 37 entries_[c & kMask] = CacheEntry(c, result[0] - c); | 35 entries_[c & kMask] = CacheEntry(c, result[0] - c); |
| 38 return 1; | 36 return 1; |
| 39 } else { | 37 } else { |
| 40 entries_[c & kMask] = CacheEntry(c, 0); | 38 entries_[c & kMask] = CacheEntry(c, 0); |
| 41 return 0; | 39 return 0; |
| 42 } | 40 } |
| 43 } else { | 41 } else { |
| 44 return length; | 42 return length; |
| 45 } | 43 } |
| 46 } | 44 } |
| 47 | 45 |
| 48 // SNIP | |
| 49 | |
| 50 } // namespace unibrow | 46 } // namespace unibrow |
| 51 | 47 |
| 52 #endif // VM_UNIBROW_INL_H_ | 48 #endif // VM_UNIBROW_INL_H_ |
| OLD | NEW |