From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 8129 invoked by alias); 6 May 2016 13:15:40 -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: X-Seq: 38410 Received: (qmail 24099 invoked from network); 6 May 2016 13:15:39 -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,FREEMAIL_FROM, T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=Q25ewovaGocQ4pv3AJl7Jgp61P48norTSTYAb7abR5o=; b=ybnZfGONKOMsOdMudfr3XX44g3TCmpS4bgB8gNdGzAWmbiIGSl1855NFyVnLBL+U2r Yn3LaE7EmxzXi9SP2I2O9tG5tXsmBg1xe7rwkJLvHup3HhF5HtuwlEfymk9uwxIXzmbq hpYIkjfNZQTgSmgTkRIPaOZVimUWyN/fBRg/0msSPwGo8D/Ea3BtQQDB8pS9nekeHJVw Dm3RqUOJhIQ65vZg/rBMLRpae+t3vHka2PyjX5haZ6UfO8EjsIecxVtFfHVPcjKUMezO 7EzmiMWVYPyrMIexORBUGKlKr2MWdiy0HeO78sf0GuDhY4Xd0WUdLq/CPO8m1N6bb1eO HdMg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=Q25ewovaGocQ4pv3AJl7Jgp61P48norTSTYAb7abR5o=; b=YurG/FFPrq+jt/TgB8qSTU/m/jQc/Mm9Gqrws+qYAl/ugh5v9iE6+dvU6eVNM5+4qS fvyrHPOOKdvpL6wb6kznYSfcjcYJa7ZMsGeAqgSwsEptkPxw8oRYnqv/8u59MUNpLZan xi2OEFTuVE7e3ErQWdCtcqAysV0/iWhRPaivatTprBcVdedxMqx/I5U3JWEsrjIdRqs0 4YkBH4udt45wYZX/BR8wHjRWvwBr12VzeDcn8gNsiyYwrEIszEnO6ysnkeTzvMM5S3Ic MJ7aHPqDdngsZtfqLIsvsrN625pkghOiQLJTjm/Wigbg9znnqiaF0OMbTPI7g/s1siwZ 0R4A== X-Gm-Message-State: AOPr4FWMFzSHaiaTiv+ZXLPqCg+xCO2OoM6eMi+PmuOTMWq/+nylqQWMBtu3BBIc6qJ6UJtTu1vqlmjQ7NbFTg== X-Received: by 10.112.142.7 with SMTP id rs7mr8604895lbb.53.1462540535442; Fri, 06 May 2016 06:15:35 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <160212014148.ZM12746@torch.brasslantern.com> References: <160111233259.ZM6719@torch.brasslantern.com> <160118223126.ZM28565@torch.brasslantern.com> <160119195608.ZM31931@torch.brasslantern.com> <20160123235303.GE20278@tarsus.local2> <160123222057.ZM16192@torch.brasslantern.com> <160210101846.ZM2333@torch.brasslantern.com> <160212014148.ZM12746@torch.brasslantern.com> From: Sebastian Gniazdowski Date: Fri, 6 May 2016 15:15:16 +0200 Message-ID: Subject: Re: Slow highlighting (Re: "drop-in replacement" and transpose-words-match) To: Bart Schaefer Cc: Zsh hackers list Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12 February 2016 at 10:41, Bart Schaefer wro= te: > On Feb 11, 11:43am, Sebastian Gniazdowski wrote: > } > } The point of this tangent example is: every indexing works by > } iterating over buffer and counting characters. > > That's only true for indexing from the end of the string (negative indice= s). > Normal indexing should be direct and very fast. I was on this some time ago. I remember, and now it also looks like being so, that following block of code does the iteration for indices >, =3D, < 0: https://github.com/zsh-users/zsh/blob/master/Src/params.c#L1348-L1394 It comes down to following loop for indices > 0: for (t =3D s; nchars && *t; nchars--) t +=3D (lastcharlen =3D MB_METACHARLE= N(t)); It counts characters (nchars--), skips bytes (lastcharlen). > } The only solution is apparently making Zsh storing strings as real > } arrays, of wint_t type. > > I'm not sure what kind of arrays you think are "real" as compared to > what zsh uses now, but vast tracts of the shell would have to be > entirely rewritten if we were to change the C string paradigm. In C one can optimize the paradigm. Carefully skip multibyte characters once, then keep and pass pointer. That optimization comes to my mind. In Zsh there are no pointers. One keeps index but it causes full reiteration each time it's used (if that's confirmed). However maybe there could be added something similar? To get special pointer: byte offset =E2=80=93 via some flag. Then, to index with byte pointer, when connected with some flag. byteoffset=3D$long_string[(x)2500] character=3D$long_string[(X)$byteoffset] Best regards, Sebastian Gniazdowski