| 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 #include "platform/assert.h" | 10 // SNIP |
| 11 | 11 |
| 12 namespace unibrow { | 12 namespace unibrow { |
| 13 | 13 |
| 14 template <class T, intptr_t s> intptr_t Mapping<T, s>::get( | 14 // SNIP |
| 15 int32_t c, int32_t n, int32_t* result) { | 15 |
| 16 template <class T, int s> int Mapping<T, s>::get(uchar c, uchar n, |
| 17 uchar* result) { |
| 16 CacheEntry entry = entries_[c & kMask]; | 18 CacheEntry entry = entries_[c & kMask]; |
| 17 if (entry.code_point_ == c) { | 19 if (entry.code_point_ == c) { |
| 18 if (entry.offset_ == 0) { | 20 if (entry.offset_ == 0) { |
| 19 return 0; | 21 return 0; |
| 20 } else { | 22 } else { |
| 21 result[0] = c + entry.offset_; | 23 result[0] = c + entry.offset_; |
| 22 return 1; | 24 return 1; |
| 23 } | 25 } |
| 24 } else { | 26 } else { |
| 25 return CalculateValue(c, n, result); | 27 return CalculateValue(c, n, result); |
| 26 } | 28 } |
| 27 } | 29 } |
| 28 | 30 |
| 29 template <class T, intptr_t s> intptr_t Mapping<T, s>::CalculateValue( | 31 template <class T, int s> int Mapping<T, s>::CalculateValue(uchar c, uchar n, |
| 30 int32_t c, int32_t n, int32_t* result) { | 32 uchar* result) { |
| 31 bool allow_caching = true; | 33 bool allow_caching = true; |
| 32 intptr_t length = T::Convert(c, n, result, &allow_caching); | 34 int length = T::Convert(c, n, result, &allow_caching); |
| 33 if (allow_caching) { | 35 if (allow_caching) { |
| 34 if (length == 1) { | 36 if (length == 1) { |
| 35 entries_[c & kMask] = CacheEntry(c, result[0] - c); | 37 entries_[c & kMask] = CacheEntry(c, result[0] - c); |
| 36 return 1; | 38 return 1; |
| 37 } else { | 39 } else { |
| 38 entries_[c & kMask] = CacheEntry(c, 0); | 40 entries_[c & kMask] = CacheEntry(c, 0); |
| 39 return 0; | 41 return 0; |
| 40 } | 42 } |
| 41 } else { | 43 } else { |
| 42 return length; | 44 return length; |
| 43 } | 45 } |
| 44 } | 46 } |
| 45 | 47 |
| 48 // SNIP |
| 49 |
| 46 } // namespace unibrow | 50 } // namespace unibrow |
| 47 | 51 |
| 48 #endif // VM_UNIBROW_INL_H_ | 52 #endif // VM_UNIBROW_INL_H_ |
| OLD | NEW |