misc cleanup

This commit is contained in:
Ailin Nemui 2022-06-13 00:48:07 +02:00
parent b028b8e19d
commit 453e65bbfe

View File

@ -394,10 +394,9 @@ view_update_line_cache(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line)
if (rec->count > 1) { if (rec->count > 1) {
for (pos = 0; lines != NULL; pos++) { for (pos = 0; lines != NULL; pos++) {
void *data = lines->data; LINE_CACHE_SUB_REC *data = lines->data;
memcpy(&rec->lines[pos], data, memcpy(&rec->lines[pos], data, sizeof(LINE_CACHE_SUB_REC));
sizeof(LINE_CACHE_SUB_REC));
lines = g_slist_remove(lines, data); lines = g_slist_remove(lines, data);
g_free(data); g_free(data);
@ -430,7 +429,7 @@ static void view_update_cache(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
view_remove_cache(view, line, update_counter); view_remove_cache(view, line, update_counter);
if (view->buffer->cur_line == line) if (view->buffer->cur_line == line)
view->cache->last_linecount = view_get_linecount(view, line); view_get_linecount(view, line);
} }
void textbuffer_view_reset_cache(TEXT_BUFFER_VIEW_REC *view) void textbuffer_view_reset_cache(TEXT_BUFFER_VIEW_REC *view)
@ -459,6 +458,7 @@ static int view_line_draw(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
unichar chr; unichar chr;
int xpos, color, drawcount, first, need_move, need_clrtoeol, char_width; int xpos, color, drawcount, first, need_move, need_clrtoeol, char_width;
unsigned int fg24, bg24; unsigned int fg24, bg24;
fg24 = bg24 = UINT_MAX;
if (view->dirty) /* don't bother drawing anything - redraw is coming */ if (view->dirty) /* don't bother drawing anything - redraw is coming */
return 0; return 0;
@ -757,7 +757,6 @@ static void view_unregister_indent_func(TEXT_BUFFER_VIEW_REC *view,
/* recreate cache so it won't contain references /* recreate cache so it won't contain references
to the indent function */ to the indent function */
textbuffer_view_reset_cache(view); textbuffer_view_reset_cache(view);
view->cache = textbuffer_cache_get(view->siblings, view->width);
} }
void textbuffer_views_unregister_indent_func(INDENT_FUNC indent_func) void textbuffer_views_unregister_indent_func(INDENT_FUNC indent_func)
@ -1073,10 +1072,10 @@ LINE_CACHE_REC *textbuffer_view_get_line_cache(TEXT_BUFFER_VIEW_REC *view,
cache = g_hash_table_lookup(view->cache->line_cache, line); cache = g_hash_table_lookup(view->cache->line_cache, line);
if (cache == NULL) if (cache == NULL)
cache = view_update_line_cache(view, line); cache = view_update_line_cache(view, line);
else else
cache->last_access = time(NULL); cache->last_access = time(NULL);
return cache; return cache;
} }
static void view_insert_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line) static void view_insert_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line)
@ -1257,12 +1256,13 @@ static void view_remove_line(TEXT_BUFFER_VIEW_REC *view, LINE_REC *line,
view_bookmarks_check(view, line); view_bookmarks_check(view, line);
if (view->buffer->cur_line == line) { if (view->buffer->cur_line == line) {
/* the last line is being removed */ /* the last line is being removed */
LINE_REC *prevline; LINE_REC *prevline;
prevline = view->buffer->first_line == line ? NULL : prevline = view->buffer->first_line == line ?
textbuffer_line_last(view->buffer)->prev; NULL :
view->cache->last_linecount = prevline == NULL ? 0 : textbuffer_line_last(view->buffer)->prev;
if (prevline != NULL)
view_get_linecount(view, prevline); view_get_linecount(view, prevline);
} }