Skip to content

url: use primordials in url.js

Follow up to #54486

@ljharb wrote

@Uzlopak especially for an internal function, in which it could easily be a security issue to provide a hook point for user code - even if it's only ever passed strings (which could also change in the future) the string methods are globally replaceable.

The funny part is that in url.js are many many non primordial function calls.And my question regarding the primordials was regarding my specific example about replacing .charCodeAt(0) with direct accessing the character of a string via index [0].

I refactored it basically to use primordials, when it makes sense.

So e.g. value.slice(i) was transformed to StringPrototypeSlice(value, i) but value.charCodeAt(0) === 58/* : */) was transformed to value[0] === ':', as it makes no sense to me to use StringPrototypeCharCodeAt.

Maybe some method calls are not transformed, which can be changed of course. I did it manually and tbh. I wanted your feedback before I continue to work on this. If you absolutely reject it in principal, than why should I invest more time anyway.

I did not bench it. Maybe somebody can run the benchmarks on the benchmark machine?

Merge request reports

Loading