Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Append to array via (P) flag
- X-seq: zsh-workers 40863
- From: Sebastian Gniazdowski <psprint3@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Append to array via (P) flag
- Date: Sat, 18 Mar 2017 10:32:21 -0700
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=fastmail.com; h= content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; bh=5o8l0ZB5ZcwUQMI3k9eEwUwGD6Q=; b= MI6eoHEm5xvVBF7g7Bnv62Tq43zRahlR+Mel7MhRTCIdtN+WXlxWkgCnqGN+8nC+ Q6UOiJBs7mUSTa7o5uXb1/rGkCF5yMjOPn6FwBDXOK1wEPj4Xb2H/DttpwB+/ldF vOb/n4D6rshCsRpbsVawFWJemJjVCg/bV12rqeRnBC5iQGFF81sD836SL1XsjpGz 9s2gLWI74SecUmqScAjEUmwTea9Uv32VGc3zsOlL4dePKM0rPMJt2i6dt7avdFeT fImJOIG5oj32pQaBljZu9Dg88c4CyfoM0pfXbVEOAZ/RIUzgzNgWuZXqlgrdRalW NM1kuaNf2hHqLizDQz4IDQ==
- Dkim-signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=5o8l0Z B5ZcwUQMI3k9eEwUwGD6Q=; b=OcA8xO/eyypFYfc5lNT1A9e/dqV2Rv8UI/cTSO TjqgFTxkctHm/0Gxaf/cPJlgZq0NI0Tv/LbC2uhACeqcvjUFuiZthsuRvouC3gG7 Iylj7P/QJgjDPW6d+nlZXHjrLDyk/IYP9e4KFrE3nkBm1PEhgK1g9LrGGBOoeQmX nKo/H9W/58XQ78HmSzH2x+YdmJ9CtBEEtOuPWrLFvwEqjdN8kYPwqTKHO1sYtKuk DOj1Zm4DMQhqlcvQONaKVtESfbL8X0Gvta2WmHE/DZk6v3E4raL4WIluZNpIkJbq m3RAzrIbRnvIBsu9Aqkw/B6DYf29sXnAA1D0Z9wjWwtqFxHA==
- In-reply-to: <170318100710.ZM24526@torch.brasslantern.com>
- List-help: <mailto:zsh-workers-help@zsh.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:zsh-workers@zsh.org>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <1489849991.578651.915517240.3CDC6181@webmail.messagingengine.com> <170318100710.ZM24526@torch.brasslantern.com>
On Sat, Mar 18, 2017, at 10:07 AM, Bart Schaefer wrote:
> On Mar 18, 8:13am, Sebastian Gniazdowski wrote:
> }
> } Problem is in API function that does:
> }
> } __output=( "${(P@)__var_name}" "New data" )
> } : ${(PA)__var_name::=${__output[@]}}
>
> You can already do this, you just need to know the length of the
> array so that you can index past the end of it:
>
> __output=("New Data" "Like this")
> __append="${__var_name}[${(P)#__var_name}+1]"
> : ${(PA)__append::=${(@)__output}}
Ok, I will have to rewrite parts of code to use that. Ran callgrind to
see the bottleneck when utilizing 5.3.1-dev-0 optimizations via the
"special construct" I mentioned:
196,685,461 arrlen [/usr/local/bin/zsh-5.3.1-dev-0_O2]
179,629,793 itype_end [/usr/local/bin/zsh-5.3.1-dev-0_O2]
159,548,348 stringsubst [/usr/local/bin/zsh-5.3.1-dev-0_O2]
85,139,775 paramsubst [/usr/local/bin/zsh-5.3.1-dev-0_O2]
84,031,867 szone_free_definite_size
[/usr/lib/system/libsystem_malloc.dylib]
61,686,940 hasbraces [/usr/local/bin/zsh-5.3.1-dev-0_O2]
58,934,416 remnulargs [/usr/local/bin/zsh-5.3.1-dev-0_O2]
Not that expected, the array of 7000 lines at final, to induce arrlen to
top. However, that's only 9% (196685461.0 / 2171855290 * 100). Wonder
what's itype_end and what stringsubst is doing.
> Out of idle curiousity, why would you write a new text editor when
> you can already use "vared" on a memory-mapped file?
For e.g. devops, to be able to use text-area in some e.g. deploy tool.
To have some buttons like "run", "restart", and a 100-lines config file
that needs just e.g. IP address alterations. The editor is just 58 lines
of code, I hope people will understand how much cheap textual-UI they
can get. vared doesn't integrate with buttons, list-boxes, etc.
Here's the editor, looks quite scary hehe:
https://asciinema.org/a/107800
--
Sebastian Gniazdowski
psprint3@xxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author