From 102a874a3a8ca376e08d1319b36833297bea39ae Mon Sep 17 00:00:00 2001 From: Neil Date: Sat, 29 Apr 2017 11:52:49 +1000 Subject: Use std::unique_ptr, std::vector, and move construction to simplify UndoHistory and make it easier to modify. Remove out of date warning suppression. --- src/CellBuffer.h | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'src/CellBuffer.h') diff --git a/src/CellBuffer.h b/src/CellBuffer.h index 8667b8bfa..8e670aca5 100644 --- a/src/CellBuffer.h +++ b/src/CellBuffer.h @@ -61,26 +61,28 @@ class Action { public: actionType at; Sci::Position position; - char *data; + std::unique_ptr data; Sci::Position lenData; bool mayCoalesce; Action(); // Deleted so Action objects can not be copied. - Action(const Action &) = delete; - void operator=(const Action &) = delete; + Action(const Action &other) = delete; + Action &operator=(const Action &other) = delete; + Action &operator=(const Action &&other) = delete; + // Move constructor allows vector to be resized without reallocating. + // Could use =default but MSVC 2013 warns. + Action(Action &&other); ~Action(); void Create(actionType at_, Sci::Position position_=0, const char *data_=0, Sci::Position lenData_=0, bool mayCoalesce_=true); - void Destroy(); - void Grab(Action *source); + void Clear(); }; /** * */ class UndoHistory { - Action *actions; - int lenActions; + std::vector actions; int maxAction; int currentAction; int undoSequenceDepth; -- cgit v1.2.3