Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A method to not leak unneeded functions
- X-seq: zsh-users 24320
- From: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>
- To: Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: A method to not leak unneeded functions
- Date: Thu, 3 Oct 2019 23:18:56 +0000
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=aJs20Wpg02kg1pDPQganR1Ri7Ar4y2ONqjH962AfNYs=; b=jOPT019ic41H6BAt3dxmkzA9ERf7waE1PJ9k6YpIR3KFnTHYt87ICMhjyMOdw9Qt6C 5y7/WeEdBgyFRZOPg2T/399NNk3CipyNOjZOZ8qaLgcv+l2W0DAibJcLDKUj9h6nKh51 7B1AKdBH7OtCtLB3yScEpTDdFkDokVpgM6fsi2+6hDBSvf529GtUm5DFqBBQYSBL/bdb MP7VmQwM8ae7ci500kFHjgVKUW7di+7QT90ckA7lMkDoCEJoB+JMnqY+CKQxSjqNHeNi +CJrsW4Elr0zlAwfraF0cfQ2KwlrZ0j+Is++YfhbFvPuLaJPXAJByVSiBW2KFHugR4Q8 YKsg==
- In-reply-to: <CAKc7PVAnQgDupk_-h85r-FtWna2KCQ+N0VS0zLynKFSydwU=MQ@mail.gmail.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- List-unsubscribe: <mailto:zsh-users-unsubscribe@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <CAKc7PVBiatCfaG5xupix8d8+VH_ScZJRRRJemUuND12Zk0TJuw@mail.gmail.com> <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
Messages sorted by:
Reverse Date,
Date,
Thread,
Author