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

Improve implementation of rstrip and lstrip #22496

Merged
merged 8 commits into from
Jun 26, 2017

Commits on Jun 23, 2017

  1. change chomp! to chomp in readchomp

    `chomp` uses `SubString` so `chomp!` is not needed to ensure that copying of big string is not performed.
    bkamins authored Jun 23, 2017
    Configuration menu
    Copy the full SHA
    2de6acf View commit details
    Browse the repository at this point in the history
  2. Remove chomp! function

    `chomp!` was only used in `readchomp` and I propose to replace it with `chomp` there. As `chomp!` was not exported I understand that it can be removed without deprecation.
    bkamins authored Jun 23, 2017
    Configuration menu
    Copy the full SHA
    b4e347e View commit details
    Browse the repository at this point in the history
  3. Make rstrip and lstrip use SubString

    In this way copying of string is avoided, and in `strip` currently the string is actually copied twice. A basic benchmark is given below:
    ```
    julia> using BenchmarkTools
    
    julia> s = " "^10*"x"^1000*" "^10;
    
    julia> @benchmark strip(s) # current definition
    BenchmarkTools.Trial:
      memory estimate:  2.13 KiB
      allocs estimate:  2
      --------------
      minimum time:     502.056 ns (0.00% GC)
      median time:      537.579 ns (0.00% GC)
      mean time:        631.383 ns (5.74% GC)
      maximum time:     6.003 μs (0.00% GC)
      --------------
      samples:          10000
      evals/sample:     197
    
    julia> @benchmark strip(s) # with SubString definition
    BenchmarkTools.Trial:
      memory estimate:  64 bytes
      allocs estimate:  2
      --------------
      minimum time:     334.062 ns (0.00% GC)
      median time:      339.819 ns (0.00% GC)
      mean time:        362.150 ns (1.00% GC)
      maximum time:     8.236 μs (93.19% GC)
      --------------
      samples:          10000
      evals/sample:     243
    ```
    bkamins authored Jun 23, 2017
    Configuration menu
    Copy the full SHA
    3bc5953 View commit details
    Browse the repository at this point in the history

Commits on Jun 24, 2017

  1. Correct strip tests

    bkamins authored Jun 24, 2017
    Configuration menu
    Copy the full SHA
    aee1c01 View commit details
    Browse the repository at this point in the history
  2. Bring back chomp!

    bkamins authored Jun 24, 2017
    Configuration menu
    Copy the full SHA
    67b19fe View commit details
    Browse the repository at this point in the history

Commits on Jun 25, 2017

  1. reverse removal of chomp!

    bkamins authored Jun 25, 2017
    Configuration menu
    Copy the full SHA
    ba34cb4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    15eb9e2 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    a7de766 View commit details
    Browse the repository at this point in the history