Siorki / RegPack

Self-contained packer for size-constrained JS code
Other
301 stars 14 forks source link

suggestion of stringHelper #99

Open da0ka opened 2 years ago

da0ka commented 2 years ago

stringHelper.js: charCodeAt returns 0-65535 or NaN. And unicode range is 0-65535. so line 32-34 50-52 is unnecessary. btw 1 << 31 is -2147483648, so c < (1 << 31) is always false

Siorki commented 2 years ago

Interestingly, the code reference I used was modified since :

https://codereview.stackexchange.com/questions/37512/count-byte-length-of-string

And the edition removes tests for values > 65535, as you suggest, and it also mentions that the computed length for characters in astral planes (i.e. represented by surrogates) is wrong:

> getByteLength( '😀' )
6 //  should be 4

Thus, issue is a bug, not simply a code simplification.