From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14096 invoked by alias); 18 Mar 2018 23:30:30 -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: 42479 Received: (qmail 1704 invoked by uid 1010); 18 Mar 2018 23:30:30 -0000 X-Qmail-Scanner-Diagnostics: from mail-pf0-f176.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.192.176):SA:0(-1.9/5.0):. Processed in 0.583525 secs); 18 Mar 2018 23:30:30 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: schaefer@brasslantern.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20150623.gappssmtp.com; s=20150623; h=from:message-id:date:in-reply-to:comments:references:to:subject :mime-version; bh=OIL8R2oXdHcsvmxxJ+nlsnPz0etZixhGiZl6B/31wwA=; b=aL1+Eh5Gaob3x1uHAcnDI3AyhXVwzYQGNlfHxBvRBUbtYKdU+Onw77Jg/p9G82UeTH jI2qFBKg/zwMI6He6bcz8/+9hn+VjNCvsnr9McQb0mnk+H+W/IcPIpXgfYCebuaXvejE SXyQtHVt8GllSrcGSn83rUXqq5hVQpPTioMjJrOv0TZq8J3HWML4e/nMkTdr/lzhgyF2 EWjA+GnyULbiCq4t+8vGXnA3fMN5DlqyKScEO+XTk4mKhnpQPsXB8dHVD3TF0lV+Z3Pq pPX9A+Qb4i3QC/BBClTdNSsOskR/ISMVBeZfSI8XSZlehFFNGXyEWNTmSOpc5xvgoEFc uUkA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version; bh=OIL8R2oXdHcsvmxxJ+nlsnPz0etZixhGiZl6B/31wwA=; b=lyglGU9d/hHwQbeTJDgJOVNx/cNCXGUfUAmg2Y8AhRtGLPY54poOE4Gm9le+yeXRv5 eyIiMEND3wSl1rs4pndsGWELN4LqiqaAf9uCc15CbanSimbHYviz8k/a7BkTrdPNe1R7 UTB0snGCahiGNXaMunfn2uS31npph6PieWXmZUlm3D4lKbI0vSqyBMMtaAHCHfWttTh2 dO4NMm+nvi9ZdXR55xmrE9VylU53fMXb9F8Z8tpSKC0+FLm9/NWE9lW0jZGzg23Nvxr5 6L4NsEctz2o+3DYxgJRqhHId2IxhyGjpmfj4HMJxhPZMme1Zjzti0/a+hP+gZXpAeALQ EMxA== X-Gm-Message-State: AElRT7GTuHbXBbav0z1Mo4X548YckHN6B3xbDUB+g/6RH56opfuh6vBp zhRLAzg+jXYKVSRUoSznr4qVwhRi X-Google-Smtp-Source: AG47ELuTI3AHW6p1umzJfn8LxQiHYNnqm4BMGbCXZAb9+vnNK8PPWj43Mr4S79hHdg1SDERPFYOqrQ== X-Received: by 10.99.95.144 with SMTP id t138mr7357157pgb.94.1521415826758; Sun, 18 Mar 2018 16:30:26 -0700 (PDT) From: Bart Schaefer Message-Id: <180318163024.ZM9068@torch.brasslantern.com> Date: Sun, 18 Mar 2018 16:30:24 -0700 In-Reply-To: <20180314024348.GA51231@CptOrmolo.darkstar> Comments: In reply to Matthew Martin "[patch] memoize string offset lookups" (Mar 13, 9:43pm) References: <20180314024348.GA51231@CptOrmolo.darkstar> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: [patch] memoize string offset lookups MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii On Mar 13, 9:43pm, Matthew Martin wrote: } } (Idea from 42227.) If you follow that thread through to 42237, the last word on the subject was that it's probably not worth it to memoize more than the single most recent call to the function. In which case it can be done with statics in the function itself, rather than by expanding the param struct and adding 20+ bytes to every parameter. We'd need some real-world information on how common it is to iterate by characters over two or more parameters in alternation, to know whether tracking every parameter separately is worth the overhead. } But in the worst case it hurts. Iterating backwards over a multibyte character array is always painful. Related to what Stephane mentions in 42466, it might be worthwhile to have another optimization in this same bit of code to do the indexing without the character counting when MB_CUR_MAX == 1. One thought: Memoize two posistions in the array, one advancing to the largest index seen so far and the other to half that, so you only have to recount about half as much if you start skipping backward. I don't have a good feel for when the record-keeping becomes more expensive than the recounting, so this may be a hare-brained scheme.