@@ -170,43 +170,25 @@ void charmap_Add(std::string const &mapping, std::vector<int32_t> &&value) {
170170 }
171171
172172 Charmap &charmap = *currentCharmap;
173- size_t nodeIdx = 0 ;
174173
174+ size_t nodeIdx = 0 ;
175175 for (char c : mapping) {
176176 nodeIdx = charmap.nextIndexOrAdd (nodeIdx, c);
177177 }
178178
179179 CharmapNode &node = charmap.nodes [nodeIdx];
180-
181180 if (node.isTerminal ()) {
182181 warning (WARNING_CHARMAP_REDEF, " Overriding charmap mapping" );
183182 }
184-
185183 std::swap (node.value , value);
186184}
187185
188- bool charmap_HasChar (std::string const &mapping) {
189- Charmap const &charmap = *currentCharmap;
190- size_t nodeIdx = 0 ;
191-
192- for (char c : mapping) {
193- nodeIdx = charmap.nodes [nodeIdx].nextIndex (c);
194-
195- if (!nodeIdx) {
196- return false ;
197- }
198- }
199-
200- return charmap.nodes [nodeIdx].isTerminal ();
201- }
202-
203186static CharmapNode const *charmapEntry (std::string const &mapping) {
204187 Charmap const &charmap = *currentCharmap;
205- size_t nodeIdx = 0 ;
206188
189+ size_t nodeIdx = 0 ;
207190 for (char c : mapping) {
208191 nodeIdx = charmap.nodes [nodeIdx].nextIndex (c);
209-
210192 if (!nodeIdx) {
211193 return nullptr ;
212194 }
@@ -215,6 +197,11 @@ static CharmapNode const *charmapEntry(std::string const &mapping) {
215197 return &charmap.nodes [nodeIdx];
216198}
217199
200+ bool charmap_HasChar (std::string const &mapping) {
201+ CharmapNode const *node = charmapEntry (mapping);
202+ return node && node->isTerminal ();
203+ }
204+
218205size_t charmap_CharSize (std::string const &mapping) {
219206 CharmapNode const *node = charmapEntry (mapping);
220207 return node && node->isTerminal () ? node->value .size () : 0 ;
0 commit comments