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

tool_getparam: cmdline option parser refactor #12631

Closed
wants to merge 10 commits into from

Conversation

bagder
Copy link
Member

@bagder bagder commented Jan 3, 2024

  • the option names are now alpha sorted and lookup is a lot faster

  • use case sensitive matching. It was previously case insensitive, but that was not documented nor tested.

  • remove "partial match" feature. It was not documented, not tested and was always fragile as existing use could break when we add a new option

  • lookup short options via a table

@bagder
Copy link
Member Author

bagder commented Jan 3, 2024

The most relevant speed tests I did with a manually added loop around the getparameter() call, trying the function in master 10 million times vs the one in this branch the same amount of times for something basic such as --verbose. This branch proved to execute more than a magnitude faster.

@bagder bagder force-pushed the bagder/sorted-options branch 3 times, most recently from d31e529 to d720a56 Compare January 4, 2024 22:13
@bagder bagder changed the title tool_getparam: bsearch cmdline options tool_getparam: cmdline option parser refactor Jan 5, 2024
@bagder bagder force-pushed the bagder/sorted-options branch 4 times, most recently from 99113fd to f10fc64 Compare January 6, 2024 22:44
bagder added a commit that referenced this pull request Jan 6, 2024
- the option names are now alpha sorted and lookup is a lot faster

- use case sensitive matching. It was previously case insensitive, but that
  was not documented nor tested.

- remove "partial match" feature. It was not documented, not tested and
  was always fragile as existing use could break when we add a new
  option

- lookup short options via a table

Closes #12631
bagder added a commit that referenced this pull request Jan 7, 2024
- the option names are now alpha sorted and lookup is a lot faster

- use case sensitive matching. It was previously case insensitive, but that
  was not documented nor tested.

- remove "partial match" feature. It was not documented, not tested and
  was always fragile as existing use could break when we add a new
  option

- lookup short options via a table

Closes #12631
bagder added a commit that referenced this pull request Jan 7, 2024
- the option names are now alpha sorted and lookup is a lot faster

- use case sensitive matching. It was previously case insensitive, but that
  was not documented nor tested.

- remove "partial match" feature. It was not documented, not tested and
  was always fragile as existing use could break when we add a new
  option

- lookup short options via a table

Closes #12631
- the option names are now alpha sorted and lookup is a lot faster

- use case sensitive matching. It was previously case insensitive, but that
  was not documented nor tested.

- remove "partial match" feature. It was not documented, not tested and
  was always fragile as existing use could break when we add a new
  option

- lookup short options via a table

Closes #12631
- easier to follow, easier to modify, easier to extend, possibly slightly
  faster

- each case now has the long option as a comment
This function is not doing post at all so it was always weirdly placed.
Saves ~11 bytes per option and simplifies the code.
To make the big switch much easier to read/understand and to make it
easier to add new options.
@bagder bagder closed this in 07dd60c Jan 8, 2024
@bagder bagder deleted the bagder/sorted-options branch January 8, 2024 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

None yet

1 participant