@@ -245,35 +245,43 @@ static void dom_find_line_and_column_using_cache(
245
245
offset = application_data -> current_input_length ;
246
246
}
247
247
248
+ size_t last_column = cache -> last_column ;
249
+ size_t last_line = cache -> last_line ;
250
+ size_t last_offset = cache -> last_offset ;
251
+
248
252
/* Either unicode or UTF-8 data */
249
253
if (application_data -> current_input_codepoints != NULL ) {
250
- while (cache -> last_offset < offset ) {
251
- if (application_data -> current_input_codepoints [cache -> last_offset ] == 0x000A /* Unicode codepoint for line feed */ ) {
252
- cache -> last_line ++ ;
253
- cache -> last_column = 1 ;
254
+ while (last_offset < offset ) {
255
+ if (application_data -> current_input_codepoints [last_offset ] == 0x000A /* Unicode codepoint for line feed */ ) {
256
+ last_line ++ ;
257
+ last_column = 1 ;
254
258
} else {
255
- cache -> last_column ++ ;
259
+ last_column ++ ;
256
260
}
257
- cache -> last_offset ++ ;
261
+ last_offset ++ ;
258
262
}
259
263
} else {
260
- while (cache -> last_offset < offset ) {
261
- const lxb_char_t current = application_data -> current_input_characters [cache -> last_offset ];
264
+ while (last_offset < offset ) {
265
+ const lxb_char_t current = application_data -> current_input_characters [last_offset ];
262
266
if (current == '\n' ) {
263
- cache -> last_line ++ ;
264
- cache -> last_column = 1 ;
265
- cache -> last_offset ++ ;
267
+ last_line ++ ;
268
+ last_column = 1 ;
269
+ last_offset ++ ;
266
270
} else {
267
271
/* See Lexbor tokenizer patch
268
272
* Note for future self: branchlessly computing the length and jumping by the length would be nice,
269
273
* however it takes so many instructions to do so that it is slower than this naive method. */
270
274
if ((current & 0b11000000 ) != 0b10000000 ) {
271
- cache -> last_column ++ ;
275
+ last_column ++ ;
272
276
}
273
- cache -> last_offset ++ ;
277
+ last_offset ++ ;
274
278
}
275
279
}
276
280
}
281
+
282
+ cache -> last_column = last_column ;
283
+ cache -> last_line = last_line ;
284
+ cache -> last_offset = last_offset ;
277
285
}
278
286
279
287
static void dom_lexbor_libxml2_bridge_tokenizer_error_reporter (
0 commit comments