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

refactor(tools/string): speed up strip (whitespace) #13168

Merged
merged 1 commit into from
Jun 12, 2024

Commits on Jun 7, 2024

  1. refactor(tools/string): speed up strip (whitespace)

    ### Summary
    
    With simple microbenchmark:
    ```lua
    ngx.update_time()
    local s = ngx.now()
    for i = 1, 100000 do
        local a = strip("           \t \ndogestr   \f\t\r ")
    end
    ngx.update_time()
    local e = ngx.now()
    
    print("took: ", (e * 1000) - (s * 1000), " ms")
    ```
    
    I get these results:
    Current: `took: 57 ms`
         PR: `took: 7 ms`
    
    Signed-off-by: Aapo Talvensaari <aapo.talvensaari@gmail.com>
    bungle committed Jun 7, 2024
    Configuration menu
    Copy the full SHA
    eba6e98 View commit details
    Browse the repository at this point in the history