clap/src
Martin Geisler b93870c10a feat: use textwrap crate for wrapping help texts
The textwrap crate uses a simpler linear-time algorithm for wrapping
the text. The current algorithm in wrap_help uses several O(n) calls
to String::insert and String::remove, which makes it potentially
quadratic in complexity.

Comparing the 05_ripgrep benchmark at commits textwrap~2 and textwrap
gives this result on my machine:

 name              before ns/iter  after ns/iter  diff ns/iter   diff %
 build_app_long    22,101          21,099               -1,002   -4.53%
 build_app_short   22,138          21,205                 -933   -4.21%
 build_help_long   514,265         284,467            -229,798  -44.68%
 build_help_short  85,720          85,693                  -27   -0.03%
 parse_clean       23,471          22,859                 -612   -2.61%
 parse_complex     29,535          28,919                 -616   -2.09%
 parse_lots        422,815         414,577              -8,238   -1.95%

As part of this commit, the wrapping_newline_chars test was updated.
The old algorithm had a subtle bug where it would break lines too
early. That is, it wrapped the text like

    ARGS:
        <mode>    x, max, maximum   20 characters, contains
                  symbols.
                  l, long           Copy-friendly,
                  14 characters, contains symbols.
                  m, med, medium    Copy-friendly, 8
                  characters, contains symbols.";

when it should really have wrapped it like

    ARGS:
        <mode>    x, max, maximum   20 characters, contains
                  symbols.
                  l, long           Copy-friendly, 14
                  characters, contains symbols.
                  m, med, medium    Copy-friendly, 8
                  characters, contains symbols.";

Notice how the word "14" was incorrectly moved to the next line. There
is clearly room for the word on the line with the "l, long" option
since there is room for "contains" just above it.

I'm not sure why this is, but the algorithm in textwrap handles this
case correctly.
2017-05-29 17:02:57 -04:00
..
app feat: use textwrap crate for wrapping help texts 2017-05-29 17:02:57 -04:00
args docs(Arg::allow_hyphen_values): updates the docs to include warnings for allow_hyphen_values and multiple(true) used together 2017-05-16 07:23:22 -04:00
completions imp(PowerShell Completions): massively dedups subcommand names in the generate script to make smaller scripts that are still functionally equiv 2017-04-18 23:17:05 -04:00
errors.rs clean up. fix lint and formatting. 2017-05-29 13:04:47 -04:00
fmt.rs remove public from Colorizer properties and use ColorizerOption instead. 2017-05-29 13:04:47 -04:00
lib.rs feat: use textwrap crate for wrapping help texts 2017-05-29 17:02:57 -04:00
macros.rs docs(clap_app!): adds using the @group specifier to the macro docs 2017-05-16 07:23:22 -04:00
osstringext.rs fix: fixes a trait that's marked private accidentlly, but should be crate internal public 2017-02-20 20:31:57 -05:00
strext.rs style: rustfmt run 2016-05-06 17:52:23 -04:00
suggestions.rs chore: clippy run 2017-03-10 08:24:30 -05:00
usage_parser.rs refactor(Arg): removes duplicate and uses Base, Switched, and Valued internally now 2017-02-20 19:06:36 -05:00