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

Micro-optimize vec.with_c_str for short vectors #9352

Merged
merged 9 commits into from Sep 27, 2013
Merged

Commits on Sep 27, 2013

  1. Configuration menu
    Copy the full SHA
    4834661 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    0bdc99d View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    2a9e763 View commit details
    Browse the repository at this point in the history
  4. std: Add benchmarks to c_str

    erickt committed Sep 27, 2013
    Configuration menu
    Copy the full SHA
    410a96c View commit details
    Browse the repository at this point in the history
  5. std: Micro-optimize vec.with_c_str for short vectors

    This now makes it unsafe to save the pointer returned by .with_c_str
    as that pointer now may be pointing at a stack allocated array.
    
    I arbitrarily chose 32 bytes as the length of the stack vector, and
    so it might not be the most optimal size.
    
    before:
    
    test c_str::bench::bench_with_c_str_long ... bench: 539 ns/iter (+/- 91)
    test c_str::bench::bench_with_c_str_medium ... bench: 97 ns/iter (+/- 2)
    test c_str::bench::bench_with_c_str_short ... bench: 70 ns/iter (+/- 5)
    
    after:
    
    test c_str::bench::bench_with_c_str_long ... bench: 542 ns/iter (+/- 13)
    test c_str::bench::bench_with_c_str_medium ... bench: 53 ns/iter (+/- 6)
    test c_str::bench::bench_with_c_str_short ... bench: 19 ns/iter (+/- 0)
    erickt committed Sep 27, 2013
    Configuration menu
    Copy the full SHA
    e02d1eb View commit details
    Browse the repository at this point in the history
  6. std: Remove an unnecessary comment from c_str

    The documentation for `.with_c_str()` already says that the pointer
    will be deallocated before returning from the function.
    erickt committed Sep 27, 2013
    Configuration menu
    Copy the full SHA
    ca66b81 View commit details
    Browse the repository at this point in the history
  7. std: Up vec.with_c_str's stack buffer to 128

    This matches @graydon's recommendation.
    erickt committed Sep 27, 2013
    Configuration menu
    Copy the full SHA
    4868273 View commit details
    Browse the repository at this point in the history
  8. std: add micro optimization to vec.with_c_str_unchecked

    before:
    
    test c_str::bench::bench_with_c_str_unchecked_long ... bench: 361 ns/iter (+/- 9)
    test c_str::bench::bench_with_c_str_unchecked_medium ... bench: 75 ns/iter (+/- 2)
    test c_str::bench::bench_with_c_str_unchecked_short ... bench: 60 ns/iter (+/- 9)
    
    after:
    
    test c_str::bench::bench_with_c_str_unchecked_long ... bench: 362 ns/iter (+/-
    test c_str::bench::bench_with_c_str_unchecked_medium ... bench: 30 ns/iter (+/- 7)
    test c_str::bench::bench_with_c_str_unchecked_short ... bench: 12 ns/iter (+/- 4)
    erickt committed Sep 27, 2013
    Configuration menu
    Copy the full SHA
    2d87803 View commit details
    Browse the repository at this point in the history
  9. std: simplify vec.with_c_str

    This also fixes a bug in `vec.with_c_str_unchecked` where we
    were not calling `.to_c_str_unchecked()` for long strings.
    erickt committed Sep 27, 2013
    5 Configuration menu
    Copy the full SHA
    b1ee87f View commit details
    Browse the repository at this point in the history