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

test: fix RegExp nits #13770

Closed
wants to merge 5 commits into from
Closed

test: fix RegExp nits #13770

wants to merge 5 commits into from

Commits on Jun 18, 2017

  1. test: remove redundant RegExp part

    RegExp part with a quantifier '0 or more' is redundant
    if it is used at the very edge of the RegExp
    and is not captured or does not affect match indices.
    vsemozhetbyt committed Jun 18, 2017
    Configuration menu
    Copy the full SHA
    9737204 View commit details
    Browse the repository at this point in the history
  2. test: remove needless RegExp flag

    In fixed case, `/g` flag is needless in the boolean context.
    vsemozhetbyt committed Jun 18, 2017
    Configuration menu
    Copy the full SHA
    035937b View commit details
    Browse the repository at this point in the history
  3. test: remove needless RegExp capturing

    Use non-capturing grouping or remove capturing completely when:
    
    * capturing is useless per se, e.g. in test() check;
    * captured groups are not used afterward at all;
    * some of the later captured groups are not used afterward.
    vsemozhetbyt committed Jun 18, 2017
    Configuration menu
    Copy the full SHA
    aa006ff View commit details
    Browse the repository at this point in the history
  4. test: use test, not match/exec in boolean context

    match() and exec() return a complicated object,
    unneeded in a boolean context.
    vsemozhetbyt committed Jun 18, 2017
    Configuration menu
    Copy the full SHA
    dc0d79c View commit details
    Browse the repository at this point in the history
  5. test: do not needlessly repeat RegExp creation

    This commit takes RegExp creation out of cycles and other repetitions.
    
    As long as the RegExp does not use /g flag and match indices,
    we are safe here.
    
    In tests, this fix hardly gives a significant performance gain,
    but it increases clarity and maintainability,
    reassuring some RegExps to be identical.
    
    RegExp in functions are not taken out of their functions:
    while these functions are called many times
    and their RegExps are recreated with each call,
    the performance gain in test cases
    does not seem to be worth decreasing function self-dependency.
    vsemozhetbyt committed Jun 18, 2017
    Configuration menu
    Copy the full SHA
    ba150cc View commit details
    Browse the repository at this point in the history