Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

readline: replace quadratic regex with linear one #26778

Closed
wants to merge 1 commit into from
Closed

readline: replace quadratic regex with linear one #26778

wants to merge 1 commit into from

Conversation

Hakerh400
Copy link
Contributor

Simplify regular expression in _wordLeft readline method.

Note: If the test can be improved in any way, let me know. Tried using FakeInput, but writing one million characters takes a very long time. Or should a benchmark be used instead of the test?

Fixes #26596

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the readline Issues and PRs related to the built-in readline module. label Mar 19, 2019
@sam-github
Copy link
Contributor

my 2 bits: I think the test should assert it functions correctly, but not the time complexity of the code. So, testing input designed to trigger quadratic isn't necessary, IMO, but if the test is fast, its not bad to do.

A comment as to why the code is written this way would be useful, so someone doesn't come along later and think "aha, I can refactor this into one line with a better regex".

@Hakerh400
Copy link
Contributor Author

Added a comment and updated the test.

Simplify regular expression in _wordLeft readline
method.
@nodejs-github-bot
Copy link
Collaborator

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 27, 2019
@targos
Copy link
Member

targos commented Mar 30, 2019

Landed in e4e2b0c

@targos targos closed this Mar 30, 2019
targos pushed a commit that referenced this pull request Mar 30, 2019
Simplify regular expression in _wordLeft and _deleteWordLeft readline
methods.

PR-URL: #26778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
BethGriggs pushed a commit that referenced this pull request Apr 5, 2019
Simplify regular expression in _wordLeft and _deleteWordLeft readline
methods.

PR-URL: #26778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
BethGriggs pushed a commit that referenced this pull request Apr 9, 2019
Simplify regular expression in _wordLeft and _deleteWordLeft readline
methods.

PR-URL: #26778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
BethGriggs pushed a commit that referenced this pull request Apr 9, 2019
Simplify regular expression in _wordLeft and _deleteWordLeft readline
methods.

PR-URL: #26778
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Signed-off-by: Beth Griggs <Bethany.Griggs@uk.ibm.com>
@BethGriggs BethGriggs mentioned this pull request Apr 9, 2019
@Hakerh400 Hakerh400 deleted the regex branch May 1, 2019 15:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. readline Issues and PRs related to the built-in readline module.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants