[m-rev.] for review: improve dir./

Peter Wang novalazy at gmail.com
Mon Sep 11 14:30:52 AEST 2023


On Mon, 11 Sep 2023 13:03:23 +1000 "Zoltan Somogyi" <zoltan.somogyi at runbox.com> wrote:
> 
> On 2023-09-11 12:59 +10:00 AEST, "Peter Wang" <novalazy at gmail.com> wrote:
> > I mean that depite the name, unsafe_index_next is not full of footguns
> > (at least, I don't think so). The usual pattern is to start from index 0,
> > then iterate through the string using the index returned by the previous
> > call to unsafe_index_next; that's safe.
> 
> I don't see how that will work, since that can just plow through
> the end of the string and keep going. You would need to compute
> the string length once, and stop when you get there. That is very similar
> to what the old code did.

unsafe_index_next(S, Index, NextIndex, Char) fails if
Index = string.length(S), so it won't keep going.

Peter


More information about the reviews mailing list