From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 896efdef for ; Sun, 11 Aug 2019 18:38:18 +0000 (UTC) Received: (qmail 10826 invoked by alias); 11 Aug 2019 18:38:13 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44649 Received: (qmail 5927 invoked by uid 1010); 11 Aug 2019 18:38:13 -0000 X-Qmail-Scanner-Diagnostics: from mail-lj1-f170.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.2/25538. spamassassin: 3.4.2. Clear:RC:0(209.85.208.170):SA:0(-1.9/5.0):. Processed in 1.585538 secs); 11 Aug 2019 18:38:13 -0000 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.208.170 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=aLZiYqou7HwZ7plcQ5Uvrewio7ZP94gzOa0eglQ6tHs=; b=oIF7j8fNJtv2DIOvjGyTyV/02eaBxLkcmcOO/SZb9/2rpS/a92yqrDi5mlyvD6mg5Q u6I5qmPmiVIg7+yZ0YD0cAJztHS3KHhguc40J6v5C4dAYxLUrPsyxVBthG3WKgEYbue8 a6uy3wamlN5KUdJTU140KKzOy5BPIsxhJ8vuHiOpJhAQCumzz00TReFsL8eoAyxu7C3r pd54RRIBLO8EK0l5uEX1pO4HSZYpBhO7vDwJu37bjMqqpNQ4Pvc2swkJLkF8MLUWE+GV 9qv2bFI17wilGl9Cd0EBCET+Kb0c4xe0qyOlV5mdm3HSwRdpR3sTkHZluJwOY6tGhWes 7LDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=aLZiYqou7HwZ7plcQ5Uvrewio7ZP94gzOa0eglQ6tHs=; b=rejPTRJ04IuOUyOUxiJ/jqvoulk0CpZKd1q/cf2p7ZKRvM6EDopVaumX2goVcu5kJr qsWWPA218gOn1txOe38FX+vxkNQLF7Hkb7n/AvT69lBaTe7QK1eEwsE5K61LfV2qRomO T2OPV/Sj8fCh+YEDOMn576zGo5K+yrXLaF9o5qZ/h/03B5XLsxoZp1aOL3OZfPbdj4ar Rv/M93ByfszBjRRkzOINlrdsqOe6c+a2ZnP4NIC1ew7BaQEIH4xK1+2m0oflE+Dt0AAO pCgx+eDROcUzTk+8RUN6C4f8xAA6+y/10xtbJtOync1MTys6xOIUbk+Af+4/lBjUUL1o t0Rg== X-Gm-Message-State: APjAAAVjbeoxE86LO71KZiPIPb4w52NDzkS0L6Tv9LyqnDZTDIThMLNk fcRnkd/+g2qTFL+E2o6Gxg0//aOWuaVgWXL+9KGrfg== X-Google-Smtp-Source: APXvYqx1VcBdVvkTpLHQ5dPakxpIJSefrb4w7gZ7jIUO2rnbGhqjsBOq1SfvvHoUTuqQg9rllIjG+Dlojlqnr7eWJP8= X-Received: by 2002:a2e:86cc:: with SMTP id n12mr16781377ljj.146.1565548657391; Sun, 11 Aug 2019 11:37:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bart Schaefer Date: Sun, 11 Aug 2019 11:37:26 -0700 Message-ID: Subject: Re: Optimizing (z)-flag To: Sebastian Gniazdowski Cc: Zsh hackers list Content-Type: text/plain; charset="UTF-8" On Sun, Aug 11, 2019 at 11:21 AM Sebastian Gniazdowski wrote: > > I'm thinking: why the (z) flag runs significantly slower that a zsh > executing the same script / text? It points that the cause should be > the way that (z) stores resulting elements. You're going to want to look at bufferwords in Src/hist.c. If memory allocation is the problem (of which I'm not convinced) it's probably because the lexer discards some tokens while building the parse tree, and bufferwords has to reconstruct the original text in some form, which often means recopying the string values that the lexer does return. I don't think it's got very much to do with actually managing the array, other than in the generic sense that parameter expansions are done by value rather than by reference and therefore the source array is copied yet again during final substitution.