mirror of
https://github.com/github/codeql.git
synced 2026-04-23 15:55:18 +02:00
This code was a bit of a performance cringe. It copied every character into a temporary array, copied that into a String, and slow-appended that onto another String. Note that the call to Characters.toChars is redundant here as advance() doesn't return a code point; it returns -1 or a UTF-16 char. The -1 case is checked for before reaching the call, so we can just cast it to a char and use it directly. We use a StringBuilder to accumulate the string. Normally it's faster to track the start/end indices and do a substring(), but that won't work in the JSDoc extractor because of the star-skipping logic in advance().