Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Append to array via (P) flag



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