zsh-workers
 help / color / mirror / code / Atom feed
* fpath+="${(u)fpath[@]}" can hog system
@ 2016-01-27  9:36 Sebastian Gniazdowski
  2016-01-27 22:50 ` Bart Schaefer
  0 siblings, 1 reply; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-01-27  9:36 UTC (permalink / raw)
  To: Zsh hackers list

Hello
Few times it was reproducing also without the loop:

repeat 20; do fpath+="${(u)fpath[@]}"; done

It's easier to reproduce this on 5.0.8 than on 5.1 and 5.2 that might
require repeated call of the loop (one repetition was sufficient on my
system). OS X 10.11.2.

Best regards
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fpath+="${(u)fpath[@]}" can hog system
  2016-01-27  9:36 fpath+="${(u)fpath[@]}" can hog system Sebastian Gniazdowski
@ 2016-01-27 22:50 ` Bart Schaefer
  2016-01-28  7:49   ` Sebastian Gniazdowski
  0 siblings, 1 reply; 3+ messages in thread
From: Bart Schaefer @ 2016-01-27 22:50 UTC (permalink / raw)
  To: Zsh hackers list

On Jan 27, 10:36am, Sebastian Gniazdowski wrote:
}
} repeat 20; do fpath+="${(u)fpath[@]}"; done

Why would you do that?  What's the intended result?

Appending a string to an array creates a single new array element; it
doesn't matter that you've used [@] inside the double quotes, you are
still appending a new single element to the array every time.  Since
the new element consists of all the previous elements joined, it is
always unique and (u) will never filter out anything.

And then all of that will be duplicated as a single colon-separated
string in $FPATH.

Yeah, if you increase the size (in bytes) of $fpath by 20! (factorial),
and then make a copy of that, you are going to consume a buttload of
resources.

If what you mean is to append new elements to the array, you want array
assignment syntax:

fpath+=("${(u)fpath[@]}")

But even that probably doesn't do what you meant. because unless you have
already done "typeset -U fpath" all the existing elements are still going
to be repeated twice ... and IF you HAVE done "typeset -U" then (u) is a
no-op.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: fpath+="${(u)fpath[@]}" can hog system
  2016-01-27 22:50 ` Bart Schaefer
@ 2016-01-28  7:49   ` Sebastian Gniazdowski
  0 siblings, 0 replies; 3+ messages in thread
From: Sebastian Gniazdowski @ 2016-01-28  7:49 UTC (permalink / raw)
  To: Bart Schaefer; +Cc: Zsh hackers list

On 27 January 2016 at 23:50, Bart Schaefer <schaefer@brasslantern.com> wrote:
> Why would you do that?  What's the intended result?

I wrote this by accident and saw my system going high load

> Yeah, if you increase the size (in bytes) of $fpath by 20! (factorial),
> and then make a copy of that, you are going to consume a buttload of
> resources.

It's a typical situation that I cannot submit a bug because it
reproduces in my long scripts but not in short examples. Sadly this
will probably another one for the collection. And in that collection
some might not be actually bugs. fpath+="${(u)fpath[@]}" hogged my
system after single execution (not in loop) in a freshly opened shell,
few times. That's all I can say. Tried this now and it doesn't
reproduce. That said your point about 20! is important, my script
loaded say 18 plugins  each time calling fpath+="${(u)fpath[@]}", so
this is how all the topic happened, and possibly it wasn't a bug...
Probably the only way to use such reports is taking a glance at
related source code and luckily noticing something

Best regards,
Sebastian Gniazdowski


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-01-28  7:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-27  9:36 fpath+="${(u)fpath[@]}" can hog system Sebastian Gniazdowski
2016-01-27 22:50 ` Bart Schaefer
2016-01-28  7:49   ` Sebastian Gniazdowski

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).