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

fast subshell



So, now that I am awake to the usefulness of subshells in a function, I'm still exploring the implications on speed since a subshell sounds like it would be a lot of work.  However, using it to  control my old friend IFS, whereasI had previously done this:


    local IFS=$'\n' # Must split on newlines only.
    all_matches=( $( whence -mavS $@ ) )
    IFS=$OLD_IFS

... now trying:


(
    IFS=$'\n' # Must split on newlines only.
    all_matches=( $( whence -mavS $@ ) )
)

... and the interesting thing is that the former executes a stress test in ca. 290 mS, but the latter in ca. 250 mS.  The difference isn't significant in the real world, but it is hard to understand, it seems strange that the subshell would be faster. Is this possible?  If so, how should I understand it?  It seems as if a subshell is a rather 'lite' thing after all, in the above it seems to be hardly more than a scoping of IFS.



Messages sorted by: Reverse Date, Date, Thread, Author