fix: skip ascii symbol in process#31
Conversation
|
It would be good to have a test with |
|
@nicolo-ribaudo Good question! This PR does not touch Currently, every items in CharacterClass is added to a single regenerate set so that we can perform possible code range concatenations. However, the regenerate lacks of the token information: i.e. the |
|
Did you see #16? |
|
Sorry I didn't see #16 before. What's happening in #16 is that However, when |
|
I'm okay with making But let’s keep the behavior for other ASCII symbols (in particular, non-printable ones) as-is. |
rewrite-pattern.js
Outdated
| break; | ||
| case 'value': | ||
| const codePoint = item.codePoint; | ||
| if (item.kind === "symbol" && codePoint >= 0x20 && codePoint <= 0x7E) { |
There was a problem hiding this comment.
Let's keep this as codePoint == 0x2D, since many ascii symbols must be escaped: [, {, |, +, ?, *, $, ...
There was a problem hiding this comment.
Escaped character, i.e. \[ is identifier kind instead of symbol kind. If regjsparser parses it safely as symbol, we don't have to escape it.
This is how /\{/ will be parsed:
{
"type": "value",
"kind": "identifier",
"codePoint": 123,
"range": [
0,
2
],
"raw": "\\{"
}9afeddb to
a710f04
Compare
|
The CI error is fixed in #81. |
|
@JLHwung could you rebase? |
a710f04 to
572314f
Compare
572314f to
e7739a1
Compare
In this PR we skip the
processItemwhen it is asymbol-kind and has code point within ASCII range.This fix will prevent
-transpiled as\\x2Dwhen it is not in character class. Besides that, it should speed up a little bit since ASCII symbols are pretty common.