mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-09 23:54:20 +02:00
Inline to_color for an easy performance boost
This commit is contained in:
@@ -133,20 +133,6 @@ set_color(ColorProfile *self, PyObject *args) {
|
||||
}
|
||||
|
||||
|
||||
uint32_t
|
||||
to_color(ColorProfile *self, uint32_t entry, uint32_t defval) {
|
||||
unsigned int t = entry & 0xFF, r;
|
||||
switch(t) {
|
||||
case 1:
|
||||
r = (entry >> 8) & 0xff;
|
||||
return self->color_table[r];
|
||||
case 2:
|
||||
return entry >> 8;
|
||||
default:
|
||||
return defval;
|
||||
}
|
||||
}
|
||||
|
||||
// Boilerplate {{{
|
||||
|
||||
|
||||
|
||||
@@ -330,7 +330,6 @@ Cursor* cursor_copy(Cursor*);
|
||||
void cursor_copy_to(Cursor *src, Cursor *dest);
|
||||
void cursor_reset_display_attrs(Cursor*);
|
||||
bool update_cell_range_data(ScreenModes *modes, SpriteMap *, Line *, unsigned int, unsigned int, ColorProfile *, const uint32_t, const uint32_t, unsigned int *);
|
||||
uint32_t to_color(ColorProfile *, uint32_t, uint32_t);
|
||||
|
||||
PyObject* line_text_at(char_type, combining_type);
|
||||
void line_clear_text(Line *self, unsigned int at, unsigned int num, int ch);
|
||||
|
||||
@@ -139,6 +139,20 @@ position_for(SpriteMap *self, PyObject *args) {
|
||||
return Py_BuildValue("III", pos->x, pos->y, pos->z);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
to_color(ColorProfile *self, uint32_t entry, uint32_t defval) {
|
||||
unsigned int t = entry & 0xFF, r;
|
||||
switch(t) {
|
||||
case 1:
|
||||
r = (entry >> 8) & 0xff;
|
||||
return self->color_table[r];
|
||||
case 2:
|
||||
return entry >> 8;
|
||||
default:
|
||||
return defval;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
update_cell_range_data(ScreenModes *modes, SpriteMap *self, Line *line, unsigned int xstart, unsigned int xmax, ColorProfile *color_profile, const uint32_t default_bg, const uint32_t default_fg, unsigned int *data) {
|
||||
SpritePosition *sp;
|
||||
|
||||
Reference in New Issue
Block a user