Re:Microsoft is updating Notepad
by mikestew on Thursday July 12, 2018 @06:55PM
(#17519300)
You know what could open large files? The editor in Visual FoxPro. Because the devs didn't assume to just load it all in memory and call it a day. No, load the piece you need to display, you can go get more from disk if you need it. Without an install in front of me, I'm pretty sure it was limited to 2Gb, though.
[ Parent
| on HN ]
Re:Microsoft is updating Notepad
by seiferteric on Thursday July 12, 2018 @08:12PM
(#17519641)
I believe memory mapping the file is the way to go.
How does an editor handle loading from disk and updating when someones inserts to the head of a file? Everything needs to be shifted.
You use a https://en.wikipedia.org/wiki/Rope_(data_structure) and not a flat string.
You only flatten the string when it's time to write to disk.
For autosave files make sure to store the changes to the rope, not the full text.
Re:Microsoft is updating Notepad
by lighttower on Thursday July 12, 2018 @10:50PM
(#17520170)
There is a comment somewhere on HN from the guy that wrote the mapping trick that Word (or WordPerfect) invented way back. They were saving changes to the file rather than flattening. I wish I could find it now.
The data structure is called a piece table, if that ids your search.