Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Possible huge setarrvalue optimization
- X-seq: zsh-workers 39972
- From: Sebastian Gniazdowski <psprint@xxxxxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: Re: Possible huge setarrvalue optimization
- Date: Thu, 17 Nov 2016 23:09:22 -0800
- 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=mesmtp; bh=HRMpgWCg0OxO0miy9vGV5XHbrM 0=; b=3I0GXDgSkbD4VuxA42ZIiRQivO3V5t/YzNXnGPDXkGSYinkmmx7ltiOHPb apgAj70zMw64wxY0Xp4ct3rml8yreUElB9bBxgX9W5RW8H2GmHFUii22wJfg/NUR G5Pu7j8Wt/cWOLQCG9T6jYrqkDivWXtRgIu3vbET7fYgNzl08=
- 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=smtpout; bh=HR MpgWCg0OxO0miy9vGV5XHbrM0=; b=kShGDb38I/CIH2bktDaL4m7OtObvD+K5U/ kLGJ99y34QVOVrcRyBfyJTWTYcmrGI4GbRUoiX7c1Uifa3AvrU9j/UhKlq63DF1e N02LhQ6563c4EvdaYQuIxrCJsyLkOQ4cVxA2PSHI34O+nSXtALKvRAFmKj00vWKy 4DJt92ZQ8=
- In-reply-to: <1479449829.1305485.791811385.14DDFE28@webmail.messagingengine.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: <1479449829.1305485.791811385.14DDFE28@webmail.messagingengine.com>
More, the optimization would apparently allow doing the following:
typeset -a arr
max_size=100
arr[max_size]=""
for (( i=1, i<=max_size, i ++ )); do
arr[i]="some data"
done
I was haunted by current implementation when writing morphogenesis
screen saver (https://asciinema.org/a/47242), it has arrays that
represent coordinates on screen:
https://github.com/psprint/zsh-morpho/blob/5b84d919b5bbb7183ae78635adb995ab4c3ee7da/zmorpho#L11-L15
I've had to use integer-indexed hashes instead of regular arrays, which
were very slow. After the opt I will be able to test is-at-least 5.3 and
use regular arrays, maybe even pre-allocated with the `max_size`
solution.
--
Sebastian Gniazdowski
psprint@xxxxxxxxxxxx
Messages sorted by:
Reverse Date,
Date,
Thread,
Author