Open Uzlopak opened 1 year ago
It looks a bit expensive. And you still call the charCodeAt
for each char in the path, right?
for (let i = 1; i < path.length; i++) {
const charCode = path.charCodeAt(i) // <-- still have the call
if (charCode === 37) {
const highCharCode = path.charCodeAt(i + 1) // <-- this call is not really expansive, bc it's not a part of the hot path. It's called only when you have an encoded char in the path
Maybe we can avoid the lowCharCode when highCharCode is not 50,51 or 52?
I would say it doesn't worth it. It's a one additional charCodeAt
call when you meet an encoded char and it's not from the list. It's definitely not a hot path. Theoratically you can reduce this call, but it might kill the code readability.
@ivan-tymoshenko What do you think about such a construction?
Also the most expensive operation seems to be te charCodeAt()-call. So maybe if we loaded highCharCode already and skip it if we should not decode that character?