Add new benchmarks, optimized search, UndoNode pool, and fix horizontal scrolling.

- Added benchmarking for GapBuffer and PieceTable (BufferBench, PerformanceSuite).
- Implemented `OptimizedSearch` using Boyer-Moore (bad character heuristic).
- Introduced `UndoNodePool` for efficient memory management.
- Fixed horizontal scrolling and cursor placement in GUI: ensured cursor visibility and improved accuracy for rendered columns.
This commit is contained in:
2025-12-03 13:53:24 -08:00
parent c98d9e717a
commit 389dcf9cc7
8 changed files with 916 additions and 48 deletions

27
OptimizedSearch.h Normal file
View File

@@ -0,0 +1,27 @@
// OptimizedSearch.h - BoyerMoore (bad character) based substring search
#ifndef KTE_OPTIMIZED_SEARCH_H
#define KTE_OPTIMIZED_SEARCH_H
#include <array>
#include <cstddef>
#include <string>
#include <vector>
class OptimizedSearch {
public:
OptimizedSearch() = default;
// Find first occurrence at or after start. Returns npos if not found.
std::size_t find_first(const std::string &text, const std::string &pattern, std::size_t start = 0);
// Find all non-overlapping matches at or after start. Returns starting indices.
std::vector<std::size_t> find_all(const std::string &text, const std::string &pattern, std::size_t start = 0);
private:
std::array<int, 256> bad_char_{};
std::string last_pat_;
void build_bad_char(const std::string &pattern);
};
#endif // KTE_OPTIMIZED_SEARCH_H