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

Don't look for empty content in the compressed archive #525

Open
bram85 opened this issue Aug 8, 2024 · 0 comments
Open

Don't look for empty content in the compressed archive #525

bram85 opened this issue Aug 8, 2024 · 0 comments

Comments

@bram85
Copy link

bram85 commented Aug 8, 2024

Some feeds never have any content in their feed, so they would have a SHA1 reference of da39a3ee5e6b4b0d3255bfef95601890afd80709 for all their entries.

elfeed-deref would look up this hash in the compressed archive first, will likely find it, decompress the archive only to return an empty string (car index) == (cdr index). This is quite some overhead only to return an empty string. I'd propose to make elfeed-ref return early whenever we face a hash that represents an empty string.

For what it's worth, I worked around it by advising elfeed-deref with the following code:

 (defun bram85-elfeed-deref-optimization (f &rest args)
    "Optimize for empty entry content.

  This is an advice meant for `elfeed-deref' (argument F) with a
  reference ID in ARGS. This advice intercepts a reference to empty
  content and immediately returns the empty string. `elfeed-deref'
  would likely find the empty content inside archive.gz, decompress
  it and only then return an empty string.

  Some feeds structurally have empty content, inducing a lot of
  overhead otherwise."
    (let ((sha1-empty-string "da39a3ee5e6b4b0d3255bfef95601890afd80709")
          (ref-id (elfeed-ref-id (car args))))
      (if (equal ref-id sha1-empty-string)
          ""
        (apply f args))))

  (advice-add 'elfeed-deref :around #'bram85-elfeed-deref-optimization)

(Source)

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

No branches or pull requests

1 participant