[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Emacs-diffs] master 52cc9a5: Reimplement inline functions in ERC wi
From: |
Stefan Monnier |
Subject: |
Re: [Emacs-diffs] master 52cc9a5: Reimplement inline functions in ERC with define-inline. |
Date: |
Sat, 18 Nov 2017 09:53:44 -0500 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
> Reimplement inline functions in ERC with define-inline.
Yay, someone dared to use define-inline even though I haven't managed to
document it yet!
Thanks.
> -(defsubst erc-dcc-unquote-filename (filename)
> - (erc-replace-regexp-in-string "\\\\\\\\" "\\"
> - (erc-replace-regexp-in-string "\\\\\"" "\""
> filename t t) t t))
> +(define-inline erc-dcc-unquote-filename (filename)
> + (inline-quote
> + (erc-replace-regexp-in-string "\\\\\\\\" "\\"
> + (erc-replace-regexp-in-string "\\\\\"" "\""
> ,filename t t) t t)))
Is it worth the trouble to inline this function at all?
I find it hard to believe that the extra function call overhead would
ever be noticeable compared to the time to do the two regexp replacements.
> -(defsubst erc-nickserv-alist-sender (network &optional entry)
> - (nth 1 (or entry (assoc network erc-nickserv-alist))))
> +(define-inline erc-nickserv-alist-sender (network &optional entry)
> + (inline-quote (nth 1 (or ,entry (assoc ,network erc-nickserv-alist)))))
When inlined, `entry` will be evaluated before `network`.
Worse yet: `network` won't be evaluated at all if `entry` is non-nil.
So it won't behave the same when inlined than when non-inlined, which
I'd consider as a bug.
AFAICT, `entry` is never passed anyway, so you could just remove it.
> -(defsubst erc-get-server-user (nick)
> +(define-inline erc-get-server-user (nick)
> "Find the USER corresponding to NICK in the current server's
> `erc-server-users' hash table."
> - (erc-with-server-buffer
> - (gethash (erc-downcase nick) erc-server-users)))
> + (inline-quote (erc-with-server-buffer
> + (gethash (erc-downcase ,nick) erc-server-users))))
This will evaluate `nick` in another buffer than the caller's
current-buffer, so if the argument refers to buffer-local variables the
result may be different when inlined than it would be when not inlined.
Stefan
- Re: [Emacs-diffs] master 52cc9a5: Reimplement inline functions in ERC with define-inline.,
Stefan Monnier <=