-
Notifications
You must be signed in to change notification settings - Fork 605
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
sidestep readline when executing a script #703
Conversation
src/prompt.c
Outdated
if (cmd && *cmd && !argv_from_string(argv, &argc, cmd)) { | ||
report("Too many arguments"); | ||
return REQ_NONE; | ||
} | ||
|
||
if (!cmd || !*cmd) { | ||
report_clear(); | ||
if (!is_script_executing()) | ||
report_clear(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this conditional behavior needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this part is not important.
How much slower was it? Persistence in the user Tig history file is definitely a big. |
The speed penalty depends on configuration and can be extreme: $ touch ~/.inputrc
$ printf 'set blink-matching-paren on\n' >> ~/.inputrc
$ TIG_SCRIPT=<(printf ':echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:quit\n') /usr/bin/time ./src/tig
2.70 real 0.09 user 0.05 sys
$ git checkout script-sidestep-readline && make > /dev/null
$ TIG_SCRIPT=<(printf ':echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:echo %%(commit)\n:quit\n') /usr/bin/time ./src/tig
0.17 real 0.08 user 0.04 sys |
65facbe
to
7a0be90
Compare
@@ -127,6 +127,20 @@ prompt_default_handler(struct input *input, struct key *key) | |||
} | |||
|
|||
static enum input_status | |||
prompt_script_handler(struct input *input, struct key *key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure if defining this is actually necessary. read_prompt_incremental
allows to pass a NULL
handler.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There might be a smarter way to do it, but the NULL
handler doesn't recognize newlines.
2718278
to
14528e5
Compare
14528e5
to
6e2a8a2
Compare
Thanks. |
Readline was causing major perf issues when interpreting a script, and inappropriately storing each script line in ~/.tig_history.
Readline was causing major perf issues when interpreting a script, and inappropriately storing each script line in
~/.tig_history
.