Remove unused code

This commit is contained in:
Kovid Goyal 2017-10-09 11:58:25 +05:30
parent f396fe59ca
commit f9b52249d1
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
3 changed files with 13 additions and 27 deletions

View File

@ -25,19 +25,15 @@
static bool send_to_gpu = true;
GraphicsManager*
grman_realloc(GraphicsManager *old, index_type lines, index_type columns) {
grman_alloc() {
GraphicsManager *self = (GraphicsManager *)GraphicsManager_Type.tp_alloc(&GraphicsManager_Type, 0);
self->lines = lines; self->columns = columns;
if (old == NULL) {
self->images_capacity = 64;
self->images = calloc(self->images_capacity, sizeof(Image));
if (self->images == NULL) {
Py_CLEAR(self); return NULL;
}
} else {
self->images_capacity = old->images_capacity; self->images = old->images; self->image_count = old->image_count;
old->images = NULL;
Py_DECREF(old);
self->images_capacity = 64;
self->images = calloc(self->images_capacity, sizeof(Image));
self->capacity = 64;
self->render_data = calloc(self->capacity, sizeof(ImageRenderData));
if (self->images == NULL || self->render_data == NULL) {
PyErr_NoMemory();
Py_CLEAR(self); return NULL;
}
return self;
}
@ -858,10 +854,8 @@ grman_handle_command(GraphicsManager *self, const GraphicsCommand *g, const uint
// Boilerplate {{{
static PyObject *
new(PyTypeObject UNUSED *type, PyObject *args, PyObject UNUSED *kwds) {
unsigned int lines, columns;
if (!PyArg_ParseTuple(args, "II", &lines, &columns)) return NULL;
PyObject *ans = (PyObject*)grman_realloc(NULL, lines, columns);
new(PyTypeObject UNUSED *type, PyObject UNUSED *args, PyObject UNUSED *kwds) {
PyObject *ans = (PyObject*)grman_alloc();
if (ans == NULL) PyErr_NoMemory();
return ans;
}

View File

@ -64,11 +64,10 @@ typedef struct {
typedef struct {
PyObject_HEAD
index_type lines, columns;
size_t image_count, images_capacity, loading_image;
GraphicsCommand last_init_graphics_command;
Image *images;
size_t count, capacity, rp_capacity;
size_t count, capacity;
ImageRenderData *render_data;
bool layers_dirty;
size_t num_of_negative_refs, num_of_positive_refs;
@ -84,7 +83,7 @@ typedef struct {
bool has_margins;
} ScrollData;
GraphicsManager* grman_realloc(GraphicsManager *, index_type lines, index_type columns);
GraphicsManager* grman_alloc();
void grman_clear(GraphicsManager*);
const char* grman_handle_command(GraphicsManager *self, const GraphicsCommand *g, const uint8_t *payload, Cursor *c, bool *is_dirty);
bool grman_update_layers(GraphicsManager *self, unsigned int scrolled_by, float screen_left, float screen_top, float dx, float dy, unsigned int num_cols, unsigned int num_rows);

View File

@ -81,7 +81,7 @@ new(PyTypeObject *type, PyObject *args, PyObject UNUSED *kwds) {
self->main_linebuf = alloc_linebuf(lines, columns); self->alt_linebuf = alloc_linebuf(lines, columns);
self->linebuf = self->main_linebuf;
self->historybuf = alloc_historybuf(MAX(scrollback, lines), columns);
self->main_grman = grman_realloc(NULL, lines, columns); self->alt_grman = grman_realloc(NULL, lines, columns);
self->main_grman = grman_alloc(); self->alt_grman = grman_alloc();
self->grman = self->main_grman;
self->main_tabstops = PyMem_Calloc(2 * self->columns, sizeof(bool));
if (self->cursor == NULL || self->main_linebuf == NULL || self->alt_linebuf == NULL || self->main_tabstops == NULL || self->historybuf == NULL || self->main_grman == NULL || self->alt_grman == NULL || self->color_profile == NULL) {
@ -152,17 +152,10 @@ screen_resize(Screen *self, unsigned int lines, unsigned int columns) {
n = realloc_lb(self->alt_linebuf, lines, columns, &num_content_lines_before, &num_content_lines_after, NULL);
if (n == NULL) return false;
Py_CLEAR(self->alt_linebuf); self->alt_linebuf = n;
GraphicsManager *g = grman_realloc(self->main_grman, lines, columns);
if (g == NULL) return false;
self->main_grman = g;
// Resize alt linebuf
g = grman_realloc(self->alt_grman, lines, columns);
if (g == NULL) return false;
self->alt_grman = g;
if (!is_main) num_content_lines = num_content_lines_after;
self->linebuf = is_main ? self->main_linebuf : self->alt_linebuf;
self->grman = is_main ? self->main_grman : self->alt_grman;
self->lines = lines; self->columns = columns;
self->margin_top = 0; self->margin_bottom = self->lines - 1;