Hi Bram,

On Fri, May 5, 2023 at 10:38 AM Bram Moolenaar <[email protected]> wrote:
>
>
> > > One more thing to keep in mind: Creating a Dict and putting items in it
> > > has quite a bit of overhead.  The two levels of Dicts means the function
> > > is not going to be efficient.  For short lists this might not matter
> > > much, but what if it is used on a long list?  Perhaps using one Dict per
> > > hunk would be OK without making it less usable.  Might even make it
> > > simpler to understand.
> > >
> >
> > I have updated the PR to reduce one level in the Dict.  I cannot make it a
> > single flat Dict as we need to separate out the "from" and "to"
> > position information.
>
> Hmm, this still uses a Dict of Dicts.
>
> It could be flattened by using a "from-" and "to-" prefix instead of
> using separate Dicts.  Is that getting too ugly?
>

The field names will be long (from-startidx, from-startbyte, from-endidx,
from-endbyte, to-startidx, to-startbyte, to-endidx and to-endbyte).

>
> There are several alternatives to represent the same information.  E.g.,
> instead of using a "start index" and "end index" it could be "index" and
> "item count".  You would then have:
>         from_index
>         from_count
>         to_index
>         to_count
>
> That looks OK to me.  Does this also work for the byte values?  How
> about:
>         from_byte
>         from_length
>

The modification can end in a line different from the starting line.  So the
from_length field needs to count the number of bytes in all the lines between
the starting line and the ending line (including the newline characters).
Then it will be difficult to compute the column number of the ending change
in the last line.  We need to use the from-startbyte and from-endbyte fields.

Regards,
Yegappan

>
>         to_byte
>         to_length
>
> It's probably a matter of taste what to call these, but at least taking
> out a level of Dict nesting will make it simpler and more efficient.
> Perhaps trying this out with the examples you can see if this also works
> for corner cases.
>

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7kh4_%2Bu1eED1fCNrNi-iDyP%2B-gQEu9LRKk0PUNWs6b-bQ%40mail.gmail.com.

Raspunde prin e-mail lui