tc39 / proposal-regexp-named-groups

Named capture groups for JavaScript RegExps
https://tc39.github.io/proposal-regexp-named-groups/
222 stars 21 forks source link

Allow named capture groups to be non-unique #1

Closed pgilad closed 8 years ago

pgilad commented 8 years ago

Why?

Performance. If the engine needs to validate there are no duplicate keys it has some overhead. Definitely in hot areas. I suggest that the last named capture group would win.

Maintaining unique names should be purely left to the end-user to take care of (or not for some use cases)

littledan commented 8 years ago

We have implemented the internals of named capture groups in V8. I don't think this is a big performance concern for us. It would be hard to unambiguously specify what the semantics are in such a case (which is generally required if JS features).

mathiasbynens commented 8 years ago

We have implemented the internals of named capture groups in V8.

For future reference, the patch @littledan mentioned is here: https://codereview.chromium.org/2050343002

I’ve created a tracking issue for future updates in V8: https://bugs.chromium.org/p/v8/issues/detail?id=5437