Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: A way to untie -T vars?
- X-seq: zsh-users 28695
- From: Roman Perepelitsa <roman.perepelitsa@xxxxxxxxx>
- To: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- Cc: Sebastian Gniazdowski <sgniazdowski@xxxxxxxxx>, Zsh Users <zsh-users@xxxxxxx>
- Subject: Re: A way to untie -T vars?
- Date: Sat, 21 Jan 2023 18:48:05 +0100
- Archived-at: <https://zsh.org/users/28695>
- In-reply-to: <CAH+w=7aEqLC4kSSMnvffNdP1XbeXhNTxvBPiL44WJc9YauPHcA@mail.gmail.com>
- List-id: <zsh-users.zsh.org>
- References: <CAKc7PVDEmKnY9TiYwaAgvzXEqNhLwZo46paUPjJOz9HsU3_djg@mail.gmail.com> <CAH+w=7aEqLC4kSSMnvffNdP1XbeXhNTxvBPiL44WJc9YauPHcA@mail.gmail.com>
On Sat, Jan 21, 2023 at 6:32 PM Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
>
> On Sat, Jan 21, 2023 at 8:38 AM Sebastian Gniazdowski
> <sgniazdowski@xxxxxxxxx> wrote:
> >
> > I'm using -U flag to quickly uniquify the scalar, however this method is problematic as the array vars are left over.
>
> Oh, now I see what you mean. You're adding an array with typeset -T
> so that -U will remove duplicates from the scalar, but then you want
> only the scalar to be left at the end -- the array is just a vehicle
> for the "uniqueness" semantics.
>
> Is using a tied array really that much faster than VAR=${(us.:.)VAR} ?
A quick test shows that VAR=${(j.:.)${(us.:.)VAR}} is slightly faster
than `typeset -T VAR _VAR`. I could see it going either way depending
on the value and what exactly is being benchmarked, but the ballpark
performance should be the same.
Roman.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author