[prefer-regexp-exec] Justification linked to on Stack Overflow is missing (and contradicted) #3389
Labels
documentation
Documentation ("docs") that needs adding/updating
duplicate
This issue or pull request already exists
package: eslint-plugin
Issues related to @typescript-eslint/eslint-plugin
[This is a documentation issue, not a code issue, so I've omitted irrelevant parts of the template; however, I have read them all!]
The documentation for this rule quotes a Stack Overflow page in support of its contention that
RegExp#exec
is faster thanString#match
if used without a global flag, and quotes the following text:I went to the given link, but could not find that text. Indeed, one answer to the question actually makes the reverse assertion:
I must admit, I don't understand either assertion, in the light of the quote from the MDN page, which is still there:
Given this, it would seem that having determined that the
g
flag is not used, any sane implementation would simply use itsRegExp#exec
to implementString#match
; in other words, I'd expect them to be the same speed.I did some simple timings with Node 14, and in fact the assertion does appear to be right in my simple test case with Node on my machine:
Regex#exec
comes out faster thanString#match
; but it would be good to have a stronger justification than a quote from a SO question that is no longer visible on the page, and preferably an explanation!Versions
@typescript-eslint/eslint-plugin
4.22.0
The text was updated successfully, but these errors were encountered: