From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: A method to not leak unneeded functions
Date: Thu, 3 Oct 2019 23:18:56 +0000 [thread overview]
Message-ID: <CAKc7PVCbEajiUZzAi1TZAh1GAKMhbGaTcKkU2_10o2WciCjQmA@mail.gmail.com> (raw)
In-Reply-To: <CAKc7PVAnQgDupk_-h85r-FtWna2KCQ+N0VS0zLynKFSydwU=MQ@mail.gmail.com>
i've noticed one thing: the need of "--" passed to unset, to be able
to unset dash-starting functions. The snippet is thus:
local -a ef
ef=( ${(k)functions} )
trap "unset -f -- \"\${(k)functions[@]:#(${(j:|:)${(q@)ef}})}\"
&>/dev/null" EXIT
trap "unset -f -- \"\${(k)functions[@]:#(${(j:|:)${(q@)ef}})}\"
&>/dev/null; return 1" INT
unset ef
That said, I've also noticed that the method is somewhat slow. For
2700 functions, the trap takes 0.39 seconds. If it could use the $ef
parameter, then it could do $${(k)functions:|ef} which I measured to
take only 1 ms. However, at the time of the EXIT trap, the local
parameters are being unset.
Is there any way to speed this up?
--
Sebastian Gniazdowski
News: https://twitter.com/ZdharmaI
IRC: https://kiwiirc.com/client/chat.freenode.net:+6697/#zplugin
Blog: http://zdharma.org
next prev parent reply other threads:[~2019-10-03 23:19 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-29 22:22 Sebastian Gniazdowski
2019-09-29 22:25 ` Sebastian Gniazdowski
2019-10-03 23:18 ` Sebastian Gniazdowski [this message]
2019-10-03 23:25 ` Sebastian Gniazdowski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKc7PVCbEajiUZzAi1TZAh1GAKMhbGaTcKkU2_10o2WciCjQmA@mail.gmail.com \
--to=sgniazdowski@gmail.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).