@@ -315,21 +315,13 @@ static vector<InstructionTextToken> ParseStringToken(
315
315
const string_view src = unprocessedStringToken.text ;
316
316
const size_t tail = src.size ();
317
317
318
- // Max parsing length set to max annotation length
319
- if (tail > maxParsingLength)
320
- return {unprocessedStringToken};
321
-
322
318
vector<InstructionTextToken> result;
323
319
size_t curStart = 0 , curEnd = 0 ;
324
320
325
- string scratch;
326
- scratch.reserve (maxParsingLength);
327
-
328
321
auto ConstructToken = [&](size_t start, size_t end)
329
322
{
330
- scratch.assign (src.data () + start, end - start);
331
323
InstructionTextToken token = unprocessedStringToken;
332
- token.text . swap (scratch );
324
+ token.text = string (src. substr (start, end - start) );
333
325
token.width = token.text .size ();
334
326
result.emplace_back (std::move (token));
335
327
};
@@ -403,6 +395,20 @@ static vector<InstructionTextToken> ParseStringToken(
403
395
{
404
396
curEnd++;
405
397
}
398
+
399
+ // Check if we've exceeded max parsing length
400
+ if (curEnd > maxParsingLength)
401
+ {
402
+ // Flush any pending token
403
+ flushToken (curStart, maxParsingLength);
404
+
405
+ // Create single token with remaining text
406
+ InstructionTextToken remainingToken = unprocessedStringToken;
407
+ remainingToken.text = string (src.substr (maxParsingLength));
408
+ remainingToken.width = remainingToken.text .size ();
409
+ result.emplace_back (std::move (remainingToken));
410
+ return result;
411
+ }
406
412
}
407
413
408
414
flushToken (curStart, curEnd);
0 commit comments