mirror of
https://github.com/clap-rs/clap
synced 2025-03-05 07:47:40 +00:00
perf: Extract non-generic part of App::new()
Saves 5K.
This commit is contained in:
parent
7774a8ee8a
commit
778bcf2ecc
1 changed files with 26 additions and 20 deletions
|
@ -116,8 +116,11 @@ impl<'help> App<'help> {
|
||||||
/// # ;
|
/// # ;
|
||||||
/// ```
|
/// ```
|
||||||
pub fn new<S: Into<String>>(name: S) -> Self {
|
pub fn new<S: Into<String>>(name: S) -> Self {
|
||||||
let name = name.into();
|
/// The actual implementation of `new`, non-generic to save code size.
|
||||||
|
///
|
||||||
|
/// If we don't do this rustc will unnecessarily generate multiple versions
|
||||||
|
/// of this code.
|
||||||
|
fn new_inner<'help>(name: String) -> App<'help> {
|
||||||
App {
|
App {
|
||||||
id: Id::from(&*name),
|
id: Id::from(&*name),
|
||||||
name,
|
name,
|
||||||
|
@ -139,6 +142,9 @@ impl<'help> App<'help> {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
new_inner(name.into())
|
||||||
|
}
|
||||||
|
|
||||||
/// Adds an [argument] to the list of valid possibilities.
|
/// Adds an [argument] to the list of valid possibilities.
|
||||||
///
|
///
|
||||||
/// # Examples
|
/// # Examples
|
||||||
|
|
Loading…
Add table
Reference in a new issue