Major changes to api and structure.
- Remove newline caching - limit petal sizes - make public facing api use points only - fix iterators (chunk & line)
This commit is contained in:
@@ -12,31 +12,15 @@ struct AppendBuffer : Buffer {
|
||||
uint32_t current_offset{0};
|
||||
uint32_t t_offset{0};
|
||||
|
||||
using LChunk = uint32_t[CHUNK_SIZE];
|
||||
std::vector<LChunk *> newlines;
|
||||
LChunk *l_current;
|
||||
uint32_t l_offset{0};
|
||||
|
||||
AppendBuffer();
|
||||
|
||||
~AppendBuffer();
|
||||
|
||||
uint32_t key(char c);
|
||||
uint32_t append(const char *text, uint32_t length, uint32_t *line_count);
|
||||
uint32_t append(const char *text, uint32_t length);
|
||||
|
||||
const char *read(uint32_t pos, uint32_t *out_len);
|
||||
uint32_t count_lines(uint32_t pos, uint32_t length);
|
||||
|
||||
uint32_t next_newline(uint32_t pos);
|
||||
uint32_t nth_newline(uint32_t pos, uint32_t n);
|
||||
|
||||
private:
|
||||
inline uint32_t newline_value_at(uint32_t flat_index);
|
||||
inline uint32_t length();
|
||||
|
||||
inline void new_text_chunk();
|
||||
inline void new_line_chunk();
|
||||
|
||||
inline uint32_t find_newline(uint32_t target, uint32_t low, uint32_t high);
|
||||
|
||||
inline uint32_t _append(const char *text, uint32_t length);
|
||||
};
|
||||
|
||||
@@ -4,8 +4,6 @@
|
||||
|
||||
struct Buffer {
|
||||
virtual const char *read(uint32_t pos, uint32_t *out_len) = 0;
|
||||
virtual uint32_t count_lines(uint32_t pos, uint32_t length) = 0;
|
||||
virtual uint32_t next_newline(uint32_t pos) = 0;
|
||||
virtual uint32_t nth_newline(uint32_t pos, uint32_t n) = 0;
|
||||
virtual inline uint32_t length() = 0;
|
||||
virtual ~Buffer() = default;
|
||||
};
|
||||
|
||||
@@ -5,16 +5,13 @@
|
||||
|
||||
struct OriginalBuffer : Buffer {
|
||||
char *buf;
|
||||
uint32_t length;
|
||||
std::vector<uint32_t> newlines;
|
||||
uint32_t len;
|
||||
|
||||
// TODO: replace with file io or even lazy loaded file io for large files/logs etc. later.
|
||||
OriginalBuffer(char *buf, uint32_t length);
|
||||
OriginalBuffer(char *buf, uint32_t len);
|
||||
|
||||
~OriginalBuffer();
|
||||
|
||||
const char *read(uint32_t pos, uint32_t *out_len);
|
||||
uint32_t count_lines(uint32_t pos, uint32_t length);
|
||||
uint32_t next_newline(uint32_t pos);
|
||||
uint32_t nth_newline(uint32_t pos, uint32_t n);
|
||||
uint32_t length();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user