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

Split up _list() and get rid of $TMP_FILE and cleanup(). #75

Merged
merged 3 commits into from Feb 15, 2012

Conversation

inkarkat
Copy link
Member

This is a refactoring and optimization enabled by the gradual obsolescence of the use of TMP_FILE. By taking a stab at the overly long _list(), and extracting _format() out of it, the listall action can be rewritten to use a pipe instead of TMP_FILE. With the last use gone, there's no need for the check and cleanup of TMP_FILE, which should speed up the script execution a tiny bit.

After the recent refactorings, the temporary file is only needed for the listall action. Therefore, the creation-checks and eventual cleanup can be restricted to the listall action, which should slightly speed up the overall script execution.
Extract a new function _format() (and getPadding(), both also exported for add-ons) from _list(), which includes the main formatting and filtering pipeline, without the file handling and verbose summary. This can receive the todo file via stdin, so the listall action is able to format the concatenated files without going through a temporary file.

Eventually, after further refactorings, _format() could be used for actual formatted verbose messages in all commands; currently, the raw, unformatted task is printed.
There's a slight chance that some add-on has used this (undocumented, unofficial) configuration value for its own purposes (and maybe also relied on the unexposed cleanup() infrastructure), but detecting and fixing that problem (by moving the cleanup into the add-on itself) is pretty straightforward.
ginatrapani added a commit that referenced this pull request Feb 15, 2012
Split up _list() and get rid of $TMP_FILE and cleanup().
@ginatrapani ginatrapani merged commit ad1ca6c into todotxt:master Feb 15, 2012
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.

None yet

2 participants