zsh-workers
 help / color / mirror / code / Atom feed
From: Sebastian Gniazdowski <psprint3@fastmail.com>
To: zsh-workers@zsh.org
Subject: Re: Append to array via (P) flag
Date: Sat, 18 Mar 2017 10:32:21 -0700	[thread overview]
Message-ID: <1489858341.606329.915611408.0E3E4DF3@webmail.messagingengine.com> (raw)
In-Reply-To: <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@fastmail.com


  reply	other threads:[~2017-03-18 17:32 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-18 15:13 Sebastian Gniazdowski
2017-03-18 17:07 ` Bart Schaefer
2017-03-18 17:32   ` Sebastian Gniazdowski [this message]
2017-03-18 21:50     ` Bart Schaefer

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=1489858341.606329.915611408.0E3E4DF3@webmail.messagingengine.com \
    --to=psprint3@fastmail.com \
    --cc=zsh-workers@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).