From b9ef6e6bb9ccafe4dff4d4d4b2564d47be754bd9 Mon Sep 17 00:00:00 2001 From: Ray Chason Date: Tue, 6 Dec 2022 18:46:43 -0500 Subject: [PATCH] Define a tail pointer for the glyph list Use the tail pointer to add new glyphs, avoiding the need to traverse the list. --- include/sym.h | 1 + src/symbols.c | 1 + src/utf8map.c | 23 ++++++----------------- 3 files changed, 8 insertions(+), 17 deletions(-) diff --git a/include/sym.h b/include/sym.h index 165492dd2..8dd14c311 100644 --- a/include/sym.h +++ b/include/sym.h @@ -157,6 +157,7 @@ struct symset_customization { int count; int custtype; struct customization_detail *details; + struct customization_detail *details_end; }; #endif /* ENHANCED_SYMBOLS */ diff --git a/src/symbols.c b/src/symbols.c index 6b21b7519..383d8b8eb 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -1200,6 +1200,7 @@ purge_custom_entries(enum graphics_sets which_set) details = next; } gdc->details = 0; + gdc->details_end = 0; if (gdc->customization_name) { free((genericptr_t) gdc->customization_name); gdc->customization_name = 0; diff --git a/src/utf8map.c b/src/utf8map.c index c62861dac..87ebb11e3 100644 --- a/src/utf8map.c +++ b/src/utf8map.c @@ -509,16 +509,15 @@ add_custom_urep_entry( { static uint32_t closecolor = 0; static int clridx = 0; - int retval = 0; struct symset_customization *gdc = &gs.sym_customizations[which_set]; - struct customization_detail *details, *prev = 0, *newdetails = 0, - *lastdetail = 0; + struct customization_detail *details, *newdetails = 0; if (!gdc->details) { gdc->customization_name = dupstr(customization_name); gdc->custtype = custom_ureps; gdc->details = 0; + gdc->details_end = 0; } details = find_matching_symset_customization(customization_name, custom_symbols, which_set); @@ -537,7 +536,6 @@ add_custom_urep_entry( details->content.urep.u.utf32ch = utf32ch; return 1; } - prev = details; details = details->next; } } @@ -554,23 +552,14 @@ add_custom_urep_entry( newdetails->content.urep.u.u256coloridx = 0; newdetails->content.urep.u.utf32ch = utf32ch; newdetails->next = (struct customization_detail *) 0; - if (!details && prev) { - prev->next = newdetails; - retval = 1; - } else if (!gdc->details) { + if (gdc->details == NULL) { gdc->details = newdetails; - retval = 1; } else { - lastdetail = gdc->details; - while (lastdetail) { - prev = lastdetail; - lastdetail = lastdetail->next; - } - prev->next = newdetails; - retval = 1; + gdc->details_end->next = newdetails; } + gdc->details_end = newdetails; gdc->count++; - return retval; + return 1; } static int -- 2.50.0