Optimization in Development Tools
Profiling has shown that DocumentRange was one of the biggest remaining memory-hogs, especially on 64-bit systems KTextEditor::Range takes much more memory than the actual content because the data is split across multiple separately allocated blocks.
Also, it is inefficient to copy around, and DocumentRanges maintain a hierarchy that isn't needed at all, but also takes a lot of memory.
Solution:
Create efficient self-contained classes SimpleRange and SimpleCursor, that are used for each duchain object. Stop using DocumentRange in DocumentRangeObject. Instead, now each duchain object has one permanently stored SimpleRange, and a SmartRange pointer that is only nonzero when the document is loaded and has a smart-range.
The SimpleRange and the SmartRange are synchronized on access.
Result:
- No more thread-unsafe range access in DocumentRangeObject::textRange()
- Significantly less memory consumption
- More efficient serializability because the SimpleRange is embedded in the shared d-pointer.
By the way the duchain initializations were cleaned up a little, and some yet unnoticed bugs there fixed.