Remove GapBuffer and associated legacy implementation.
- Deleted `GapBuffer` class and its API implementations. - Removed `AppendBuffer` selector and conditional `KTE_USE_PIECE_TABLE` macros. - Eliminated legacy support in buffer APIs, file I/O, benchmarks, and correctness tests. - Updated guidelines and comments to reflect PieceTable as the default and only buffer backend.
This commit is contained in:
30
Buffer.h
30
Buffer.h
@@ -9,10 +9,7 @@
|
||||
#include <vector>
|
||||
#include <string_view>
|
||||
|
||||
#include "AppendBuffer.h"
|
||||
#ifdef KTE_USE_BUFFER_PIECE_TABLE
|
||||
#include "PieceTable.h"
|
||||
#endif
|
||||
#include "UndoSystem.h"
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
@@ -66,11 +63,7 @@ public:
|
||||
|
||||
[[nodiscard]] std::size_t Nrows() const
|
||||
{
|
||||
#ifdef KTE_USE_BUFFER_PIECE_TABLE
|
||||
return content_LineCount_();
|
||||
#else
|
||||
return nrows_;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -86,7 +79,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
// Line wrapper backed by AppendBuffer (GapBuffer/PieceTable)
|
||||
// Line wrapper backed by PieceTable
|
||||
class Line {
|
||||
public:
|
||||
Line() = default;
|
||||
@@ -183,7 +176,7 @@ public:
|
||||
// minimal find() to support search within a line
|
||||
[[nodiscard]] std::size_t find(const std::string &needle, const std::size_t pos = 0) const
|
||||
{
|
||||
// Materialize to std::string for now; Line is backed by AppendBuffer
|
||||
// Materialize to std::string for now; Line is backed by PieceTable
|
||||
const auto s = static_cast<std::string>(*this);
|
||||
return s.find(needle, pos);
|
||||
}
|
||||
@@ -256,29 +249,21 @@ public:
|
||||
}
|
||||
|
||||
|
||||
AppendBuffer buf_;
|
||||
PieceTable buf_;
|
||||
};
|
||||
|
||||
|
||||
[[nodiscard]] const std::vector<Line> &Rows() const
|
||||
{
|
||||
#ifdef KTE_USE_BUFFER_PIECE_TABLE
|
||||
ensure_rows_cache();
|
||||
return rows_;
|
||||
#else
|
||||
return rows_;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
[[nodiscard]] std::vector<Line> &Rows()
|
||||
{
|
||||
#ifdef KTE_USE_BUFFER_PIECE_TABLE
|
||||
ensure_rows_cache();
|
||||
return rows_;
|
||||
#else
|
||||
return rows_;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -477,13 +462,8 @@ private:
|
||||
std::size_t rx_ = 0; // render x (tabs expanded)
|
||||
std::size_t nrows_ = 0; // number of rows
|
||||
std::size_t rowoffs_ = 0, coloffs_ = 0; // viewport offsets
|
||||
#ifdef KTE_USE_BUFFER_PIECE_TABLE
|
||||
mutable std::vector<Line> rows_; // materialized cache of rows (without trailing newlines)
|
||||
#else
|
||||
std::vector<Line> rows_; // buffer rows (without trailing newlines)
|
||||
#endif
|
||||
#ifdef KTE_USE_BUFFER_PIECE_TABLE
|
||||
// When using the adapter, PieceTable is the source of truth.
|
||||
// PieceTable is the source of truth.
|
||||
PieceTable content_{};
|
||||
mutable bool rows_cache_dirty_ = true; // invalidate on edits / I/O
|
||||
|
||||
@@ -492,7 +472,7 @@ private:
|
||||
|
||||
// Helper to query content_.LineCount() while keeping header minimal
|
||||
std::size_t content_LineCount_() const;
|
||||
#endif
|
||||
|
||||
std::string filename_;
|
||||
bool is_file_backed_ = false;
|
||||
bool dirty_ = false;
|
||||
|
||||
Reference in New Issue
Block a user