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

cache colors for speed and other cleanup #3

Merged
merged 1 commit into from May 13, 2019

Conversation

@bahamas10
Copy link
Contributor

@bahamas10 bahamas10 commented Aug 28, 2018

hi, I just switched over to void linux and I'm huge fan of vpm! I made a lot of changes, some big some small, the most important are:

  1. consistent quoting (and not quoting) of variables to avoid potential disaster with word-spltting
  2. caching colors from tput to avoid unnecessary forks to external commands
  3. way faster string parsing for vpm list

Color

When --color is auto or left unspecified (same behavior), this program will now simply look to see that 1. stdout is a TTY and 2. $TERM has the word color in it somewhere. If both of those are true, color will be enabled.

The color output from tput is stored in the variables themselves so outputting them over and over again is very fast.

For example, with vpm list with color output, I'm able to list 400 packages on my machine in 80ms with my patch as opposed to 3.6s with the current version of vpm.

$ time vpm --color=on list | wc -l
400

real	0m0.078s
user	0m0.052s
sys	0m0.033s
$ time old.vpm --color=on list | wc -l
400

real	0m3.626s
user	0m2.189s
sys	0m1.998s
Copy link
Owner

@netzverweigerer netzverweigerer left a comment

Sorry for not looking into this for such a long time. Approved.

@netzverweigerer netzverweigerer merged commit b25763b into netzverweigerer:master May 13, 2019
pbui added a commit to pbui/void-setup that referenced this pull request May 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants
You can’t perform that action at this time.