File loading in mcedit reorganized



Hello!

I have fixed a bug when the internal editor would blindly trust the file
size instead of reading the file until the file ends.  While doing that, I
had to reorganize the code for file loading.  The new code basically does
the same thing, but it's easier to understand.

The internal editor always loads the whole file into memory.  I was wrong
when I objected that loading large files would limit the file size - this
limitation already exists.

There are two ways to load a file.  Fast loading reads the files directly
into the buffers.  The buffers (edit->buffer2[]) are allocated in such way
that the beginning of the file is in the last allocated buffer and may not
use the whole buffer, while the end of the file is using the first buffer.
This means that the fast loading is impossible unless the file size is
known.  I hope to fix it, but probably after the release.

Slow loading is done byte-by-byte.  It is used when a filter is used for
the file.  Now it's also used on non-local VFS, because the overhead of
loading is negligible compared with VFS overhead, whereas VFS can be wrong
about the file size (as it was the case with mailfs until yesterday).

CR/LF translation should also be done by disabling fast loading.  I think
the current code is much better suited for adding CR/LF translation.  I
didn't feel safe about adding new code on top of the mess that was there
before.

-- 
Regards,
Pavel Roskin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]