mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-12 19:49:32 +02:00
Move ByteLoader back to simd-string.c in preparation for getting rid of it
This commit is contained in:
@@ -20,6 +20,17 @@ _Pragma("clang diagnostic pop")
|
||||
static bool has_sse4_2 = false, has_avx2 = false;
|
||||
|
||||
// ByteLoader {{{
|
||||
#define BYTE_LOADER_T unsigned long long
|
||||
typedef struct ByteLoader {
|
||||
BYTE_LOADER_T m;
|
||||
unsigned sz_of_next_load, digits_left, num_left;
|
||||
const uint8_t *next_load_at;
|
||||
} ByteLoader;
|
||||
uint8_t byte_loader_peek(const ByteLoader *self);
|
||||
void byte_loader_init(ByteLoader *self, const uint8_t *buf, unsigned int sz);
|
||||
uint8_t byte_loader_next(ByteLoader *self);
|
||||
|
||||
|
||||
uint8_t
|
||||
byte_loader_peek(const ByteLoader *self) {
|
||||
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
|
||||
@@ -12,16 +12,6 @@
|
||||
#include <stdalign.h>
|
||||
#include "data-types.h"
|
||||
|
||||
#define BYTE_LOADER_T unsigned long long
|
||||
typedef struct ByteLoader {
|
||||
BYTE_LOADER_T m;
|
||||
unsigned sz_of_next_load, digits_left, num_left;
|
||||
const uint8_t *next_load_at;
|
||||
} ByteLoader;
|
||||
uint8_t byte_loader_peek(const ByteLoader *self);
|
||||
void byte_loader_init(ByteLoader *self, const uint8_t *buf, unsigned int sz);
|
||||
uint8_t byte_loader_next(ByteLoader *self);
|
||||
|
||||
typedef void (*control_byte_callback)(void *data, uint8_t ch);
|
||||
typedef void (*output_chars_callback)(void *data, const uint32_t *chars, unsigned count);
|
||||
|
||||
|
||||
@@ -207,7 +207,6 @@ typedef struct PS {
|
||||
struct { size_t offset, sz, pending; } write;
|
||||
alignas(BUF_EXTRA) uint8_t buf[BUF_SZ + BUF_EXTRA];
|
||||
} PS;
|
||||
static_assert(offsetof(PS, buf) > sizeof(BYTE_LOADER_T), "There must be enough space before the buf[] array for aligned loads");
|
||||
|
||||
static void
|
||||
reset_csi(ParsedCSI *csi) {
|
||||
@@ -987,17 +986,16 @@ bool
|
||||
parse_sgr(Screen *screen, const uint8_t *buf, unsigned int num, const char *report_name UNUSED, bool is_deccara) {
|
||||
ParsedCSI csi = {.mult=1};
|
||||
size_t pos = 0;
|
||||
RAII_ALLOC(uint8_t, _buf, malloc(num + 2 + 2*sizeof(BYTE_LOADER_T)));
|
||||
RAII_ALLOC(uint8_t, _buf, malloc(num + 3));
|
||||
if (!_buf) return false;
|
||||
uint8_t *safe_buf = _buf + sizeof(BYTE_LOADER_T);
|
||||
memcpy(safe_buf, buf, num);
|
||||
memcpy(_buf, buf, num);
|
||||
if (is_deccara) {
|
||||
safe_buf[num++] = '$'; safe_buf[num++] = 'r';
|
||||
_buf[num++] = '$'; _buf[num++] = 'r';
|
||||
} else {
|
||||
safe_buf[num++] = 'm';
|
||||
_buf[num++] = 'm';
|
||||
}
|
||||
safe_buf[num] = 0;
|
||||
if (!csi_parse_loop((PS*)screen->vt_parser->state, &csi, safe_buf, &pos, num, 0)) return false;
|
||||
_buf[num] = 0;
|
||||
if (!csi_parse_loop((PS*)screen->vt_parser->state, &csi, _buf, &pos, num, 0)) return false;
|
||||
return _parse_sgr((PS*)screen->vt_parser->state, &csi);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user