diff options
author | Neil <nyamatongwe@gmail.com> | 2024-02-01 12:38:58 +1100 |
---|---|---|
committer | Neil <nyamatongwe@gmail.com> | 2024-02-01 12:38:58 +1100 |
commit | fa3f060e142243c7848284f16561d4af9f9ee935 (patch) | |
tree | 55975d3c9f1b13b38686424b4dc2c4daf314a052 /src/CellBuffer.cxx | |
parent | 252cb0fe25a8cbbce19944033e311203e0fb07dc (diff) | |
download | scintilla-mirror-fa3f060e142243c7848284f16561d4af9f9ee935.tar.gz |
Store undo text in ScrapStack, a single allocation instead of one allocation per
step. This saves about 50% for a long sequence of single byte actions.
Diffstat (limited to 'src/CellBuffer.cxx')
-rw-r--r-- | src/CellBuffer.cxx | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/src/CellBuffer.cxx b/src/CellBuffer.cxx index fd6fe55fb..01074d666 100644 --- a/src/CellBuffer.cxx +++ b/src/CellBuffer.cxx @@ -1088,16 +1088,11 @@ int CellBuffer::StartUndo() noexcept { } Action CellBuffer::GetUndoStep() const noexcept { - const UndoAction &actionStep = uh->GetUndoStep(); - Action acta{ actionStep.at, actionStep.mayCoalesce, actionStep.position, nullptr, actionStep.lenData }; - if (actionStep.lenData) { - acta.data = actionStep.data.get(); - } - return acta; + return uh->GetUndoStep(); } void CellBuffer::PerformUndoStep() { - const UndoAction &actionStep = uh->GetUndoStep(); + const Action actionStep = uh->GetUndoStep(); if (changeHistory && uh->BeforeSavePoint()) { changeHistory->StartReversion(); } @@ -1112,7 +1107,7 @@ void CellBuffer::PerformUndoStep() { } BasicDeleteChars(actionStep.position, actionStep.lenData); } else if (actionStep.at == ActionType::remove) { - BasicInsertString(actionStep.position, actionStep.data.get(), actionStep.lenData); + BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData); if (changeHistory) { changeHistory->UndoDeleteStep(actionStep.position, actionStep.lenData, uh->AfterDetachPoint()); } @@ -1129,18 +1124,13 @@ int CellBuffer::StartRedo() noexcept { } Action CellBuffer::GetRedoStep() const noexcept { - const UndoAction &actionStep = uh->GetRedoStep(); - Action acta {actionStep.at, actionStep.mayCoalesce, actionStep.position, nullptr, actionStep.lenData}; - if (actionStep.lenData) { - acta.data = actionStep.data.get(); - } - return acta; + return uh->GetRedoStep(); } void CellBuffer::PerformRedoStep() { - const UndoAction &actionStep = uh->GetRedoStep(); + Action actionStep = uh->GetRedoStep(); if (actionStep.at == ActionType::insert) { - BasicInsertString(actionStep.position, actionStep.data.get(), actionStep.lenData); + BasicInsertString(actionStep.position, actionStep.data, actionStep.lenData); if (changeHistory) { changeHistory->Insert(actionStep.position, actionStep.lenData, collectingUndo, uh->BeforeSavePoint() && !uh->AfterDetachPoint()); |