File tree Expand file tree Collapse file tree 1 file changed +9
-28
lines changed
shared/regex/codeql/regex/nfa Expand file tree Collapse file tree 1 file changed +9
-28
lines changed Original file line number Diff line number Diff line change @@ -1327,38 +1327,19 @@ module Make<RegexTreeViewSig TreeImpl> {
1327
1327
private string escapeUnicodeChar ( string char ) {
1328
1328
if isPrintable ( char )
1329
1329
then result = char
1330
- else result = "\\u" + to4digitNumber ( toHex ( any ( int i | i .toUnicode ( ) = char ) ) )
1330
+ else result = "\\u" + to4digitHex ( any ( int i | i .toUnicode ( ) = char ) )
1331
1331
}
1332
1332
1333
1333
/**
1334
- * Gets a string representation of `number` in hexadecimal.
1335
- * Works for the first 200000 numbers, which is enough for every unicode character.
1334
+ * Gets a 4-digit hex representation of `i`.
1336
1335
*/
1337
- private string toHex ( int number ) {
1338
- number = [ 0 .. 200000 ] and
1339
- if number <= 9
1340
- then result = number + ""
1341
- else
1342
- if number <= 15
1343
- then result = "abcdef" .charAt ( number - 10 )
1344
- else result = toHex ( number / 16 ) + toHex ( number % 16 )
1345
- }
1346
-
1347
- /** Gets a string where 0 has been prepended to `num` until it has length 4. */
1348
- bindingset [ num]
1349
- private string to4digitNumber ( string num ) {
1350
- if num .length ( ) >= 4
1351
- then result = num
1352
- else
1353
- if num .length ( ) = 3
1354
- then result = "0" + num
1355
- else
1356
- if num .length ( ) = 2
1357
- then result = "00" + num
1358
- else
1359
- if num .length ( ) = 1
1360
- then result = "000" + num
1361
- else result = "0000"
1336
+ bindingset [ i]
1337
+ string to4digitHex ( int i ) {
1338
+ result =
1339
+ "0123456789abcdef" .charAt ( i .bitShiftRight ( 12 ) .bitAnd ( 15 ) ) +
1340
+ "0123456789abcdef" .charAt ( i .bitShiftRight ( 8 ) .bitAnd ( 15 ) ) +
1341
+ "0123456789abcdef" .charAt ( i .bitShiftRight ( 4 ) .bitAnd ( 15 ) ) +
1342
+ "0123456789abcdef" .charAt ( i .bitAnd ( 15 ) )
1362
1343
}
1363
1344
1364
1345
/** Holds if `char` is easily printable char, or whitespace. */
You can’t perform that action at this time.
0 commit comments