Skip to content

Conversation

@cxw42
Copy link

@cxw42 cxw42 commented Apr 7, 2019

Kyle, thanks for this tool, which I have been using for a year or two now with great success! Today I was trying out the Devel::NYTProf profiler on git-log-compact and noticed that most of the time went into qx() calls. I investigated, and found that most of them were calls to git config.

This PR has several commits, each of which permits replacing a qx(git config ...) call with a command-line parameter or default. On a test repo I have with about twenty commits, the time to run git-log-compact dropped from about one second to about 200 ms with these changes.

The last commit also adds an environment variable that can be used to hold the defaults, so you don't even have to call git config to get those!

Please let me know if you have any questions or comments. Thank you very much for considering this PR!

Chris (cpan: CXW)

Chris White added 6 commits April 7, 2019 11:44
This is to make it easier for others to contribute.
This way you can skip the call to `git var GIT_PAGER` if the user has
set `--pager` in `log-compact.defaults`.
This option, when specified, means we don't have to run
`git config --get-color`, which greatly reduces the time spent in qx()
(aka CORE:backtick in Devel::NYTProf).

- Added command-line option
- Added a copy of Term::ANSIColor::Simple, which has compatible licensing
- Updated the copy to remove implicit reset (`ESC [0m`) and add an
  explicit reset sub

Also:
- Updated the copyright notice to include "and contributors"
- Added a contributors list to the README
It was checking whether we were in a git repo.  However, the open() call
to open `git log` also tells us that, so the rev-parse check was
redundant.  The only other `git` call before the `git log` is a
`git --exec-path`, which doesn't care whether or not we're in a repo.

I also added some comments to mark major parts of the script.
This variable, if it exists, is used instead of `log-compact.defaults`.
This speeds up git-log-compact, since it eliminates a `git config` call.
Also removed the `use` statements for Exporter and overload, which
reduces compilation time.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant