Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm
Precedence: bulk
X-No-Archive: yes
List-Id: Zsh Workers List <zsh-workers.zsh.org>
List-Post: <mailto:zsh-workers@zsh.org>
List-Help: <mailto:zsh-workers-help@zsh.org>
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> <CAKc7PVDhxbVgmV7WcGgyDzMmWSjwQ=7=LExXTwr7YvPzPpn2RA@mail.gmail.com>
 <160118223126.ZM28565@torch.brasslantern.com> <CAKc7PVB-X+DYVEHRqSoOiDAjNeTsVyz=EN72FHQuF=AnRmh65A@mail.gmail.com>
 <160119195608.ZM31931@torch.brasslantern.com> <20160123235303.GE20278@tarsus.local2>
 <160123222057.ZM16192@torch.brasslantern.com> <CAKc7PVCJFXCt+EVkYw3B7NDAUvdphgUuX6yjbt8mQYbv1Mx01w@mail.gmail.com>
 <160210101846.ZM2333@torch.brasslantern.com> <CAKc7PVAvJrGbzHrO8zwK_BxLdXH5knQNkiNrb0cE2h4Rh9A_Kg@mail.gmail.com>
 <160212014148.ZM12746@torch.brasslantern.com>
From: Sebastian Gniazdowski <sgniazdowski@gmail.com>
Date: Fri, 6 May 2016 15:15:16 +0200
Message-ID: <CAKc7PVCp1oB7T2Fq8mExLq7C3kBAM3NBxkPz6=gWz98yxUikVA@mail.gmail.com>
Subject: Re: Slow highlighting (Re: "drop-in replacement" and transpose-words-match)
To: Bart Schaefer <schaefer@brasslantern.com>
Cc: Zsh hackers list <zsh-workers@zsh.org>
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable
X-Seq: zsh-workers 38410

On 12 February 2016 at 10:41, Bart Schaefer <schaefer@brasslantern.com> 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

