|
28 | 28 | #define THIRD_PARTY_TENSORFLOW_TEXT_CORE_KERNELS_DARTS_CLONE_TRIE_WRAPPER_H_
|
29 | 29 |
|
30 | 30 | #include <stdint.h>
|
| 31 | +#include <string.h> |
31 | 32 |
|
32 | 33 | #include "absl/status/statusor.h"
|
33 | 34 |
|
@@ -81,7 +82,7 @@ class DartsCloneTrieWrapper {
|
81 | 82 | // Traverses one step from 'cursor' following 'ch'. If successful (i.e., there
|
82 | 83 | // exists such an edge), moves 'cursor' to the new node and returns true.
|
83 | 84 | // Otherwise, does nothing (i.e., 'cursor' is not changed) and returns false.
|
84 |
| - bool TryTraverseOneStep(TraversalCursor& cursor, char ch) const { |
| 85 | + bool TryTraverseOneStep(TraversalCursor& cursor, unsigned char ch) const { |
85 | 86 | const uint32_t next_node_id = cursor.node_id ^ offset(cursor.unit) ^ ch;
|
86 | 87 | const uint32_t next_node_unit = trie_array_[next_node_id];
|
87 | 88 | if (label(next_node_unit) != ch) {
|
@@ -124,9 +125,10 @@ class DartsCloneTrieWrapper {
|
124 | 125 | uint32_t cur_id = cursor.node_id;
|
125 | 126 | uint32_t cur_unit = cursor.unit;
|
126 | 127 | for (; size > 0; --size, ++ptr) {
|
127 |
| - cur_id ^= offset(cur_unit) ^ *ptr; |
| 128 | + const unsigned char ch = static_cast<const unsigned char>(*ptr); |
| 129 | + cur_id ^= offset(cur_unit) ^ ch; |
128 | 130 | cur_unit = trie_array_[cur_id];
|
129 |
| - if (label(cur_unit) != *ptr) { |
| 131 | + if (label(cur_unit) != ch) { |
130 | 132 | return false;
|
131 | 133 | }
|
132 | 134 | }
|
|
0 commit comments