kward / shflags

shFlags is a port of the Google gflags library for Unix shell.
Apache License 2.0
283 stars 45 forks source link

Add builtin equivalent for _flags_itemInList #40

Closed dnschneid closed 7 years ago

dnschneid commented 8 years ago

Speeds up shflags_test_parsing by 13%: Before: ./shflags_test_parsing.sh 0.27s user 0.21s system 10% cpu 4.727 total After: ./shflags_test_parsing.sh 0.18s user 0.18s system 8% cpu 4.176 total

I kinda poked around to see if there were other low-hanging fruit for optimization, but didn't find much. Interestingly enough, not having a _flags_useBuiltin check in _flags_itemInList saves 100ms alone, so it would seem a lot of time is spent in being robust.

kward commented 7 years ago

Thank you for the pull request. I tried patching it in, and ran into issues with some shells that support built-ins, but didn't accept the multi-level substitution. I'm going with another solution offered in https://github.com/kward/shflags/pull/33 (assuming that user tweaks the code as requested) as it is also pure shell based, and passed all my tests.