[Toybox] [PATCH] vi: Replace linelist with Piece table based design
Jarno Mäkipää
jmakip87 at gmail.com
Sun Feb 2 05:52:42 PST 2020
I think this can be applied now. Unless someone is against it. Im
personally starting to be happy with it. All tests pass, more tests
can be written.
(applies directly to master, on top or without tests patch send few minutes ago)
Replaced dlist linelist with continuous memory blocks. This will allow
editing huge files without billion mallocs. File is first opened with
mmap() and mapped region is fully described in block_list as one block.
Currently "valid" data is described as slices, when first loading file
there is only one slice that points to memory existing in block_list.
When cutting text, block_list is not freed or modified, but instead
slice_list is modified to have "hole" between 2 slices. when inserting
new mem_block is added, previos slices are cut in cursor position and
new slice is added...
Added functions to handling data inside block_list+slice_list
insert_str(), cut_str() are used for all delete and add operations
text_strrchr(), text_strchr() are used for searching lineendings
text_byte(), text_codepoint(), text_getline() are for simple data access
Implemented: more or less all previous functionality
Implemented more proper file write:
file is saved to .swp, blocks are unloaded, file permissions are copied,
and atomic rename is called, block is reloaded
chmod some defaults(rw-rw-r--) if original file could not be fstat (does
not exist)
FIX make all tests pass
Removed: Some unused functions
---
toys/pending/vi.c | 1347 +++++++++++++++++++++++++++++++----------------------
1 file changed, 791 insertions(+), 556 deletions(-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-vi-Replace-linelist-with-Piece-table-based-design.patch
Type: text/x-patch
Size: 53629 bytes
Desc: not available
URL: <http://lists.landley.net/pipermail/toybox-landley.net/attachments/20200202/ee03bdd5/attachment-0002.bin>
More information about the Toybox
mailing list