Define a tail pointer for the glyph list

Use the tail pointer to add new glyphs, avoiding the need to traverse
the list.
This commit is contained in:
Ray Chason
2022-12-06 18:46:43 -05:00
parent e556af78ec
commit b9ef6e6bb9
3 changed files with 8 additions and 17 deletions

View File

@@ -157,6 +157,7 @@ struct symset_customization {
int count; int count;
int custtype; int custtype;
struct customization_detail *details; struct customization_detail *details;
struct customization_detail *details_end;
}; };
#endif /* ENHANCED_SYMBOLS */ #endif /* ENHANCED_SYMBOLS */

View File

@@ -1200,6 +1200,7 @@ purge_custom_entries(enum graphics_sets which_set)
details = next; details = next;
} }
gdc->details = 0; gdc->details = 0;
gdc->details_end = 0;
if (gdc->customization_name) { if (gdc->customization_name) {
free((genericptr_t) gdc->customization_name); free((genericptr_t) gdc->customization_name);
gdc->customization_name = 0; gdc->customization_name = 0;

View File

@@ -509,16 +509,15 @@ add_custom_urep_entry(
{ {
static uint32_t closecolor = 0; static uint32_t closecolor = 0;
static int clridx = 0; static int clridx = 0;
int retval = 0;
struct symset_customization *gdc = &gs.sym_customizations[which_set]; struct symset_customization *gdc = &gs.sym_customizations[which_set];
struct customization_detail *details, *prev = 0, *newdetails = 0, struct customization_detail *details, *newdetails = 0;
*lastdetail = 0;
if (!gdc->details) { if (!gdc->details) {
gdc->customization_name = dupstr(customization_name); gdc->customization_name = dupstr(customization_name);
gdc->custtype = custom_ureps; gdc->custtype = custom_ureps;
gdc->details = 0; gdc->details = 0;
gdc->details_end = 0;
} }
details = find_matching_symset_customization(customization_name, details = find_matching_symset_customization(customization_name,
custom_symbols, which_set); custom_symbols, which_set);
@@ -537,7 +536,6 @@ add_custom_urep_entry(
details->content.urep.u.utf32ch = utf32ch; details->content.urep.u.utf32ch = utf32ch;
return 1; return 1;
} }
prev = details;
details = details->next; details = details->next;
} }
} }
@@ -554,23 +552,14 @@ add_custom_urep_entry(
newdetails->content.urep.u.u256coloridx = 0; newdetails->content.urep.u.u256coloridx = 0;
newdetails->content.urep.u.utf32ch = utf32ch; newdetails->content.urep.u.utf32ch = utf32ch;
newdetails->next = (struct customization_detail *) 0; newdetails->next = (struct customization_detail *) 0;
if (!details && prev) { if (gdc->details == NULL) {
prev->next = newdetails;
retval = 1;
} else if (!gdc->details) {
gdc->details = newdetails; gdc->details = newdetails;
retval = 1;
} else { } else {
lastdetail = gdc->details; gdc->details_end->next = newdetails;
while (lastdetail) {
prev = lastdetail;
lastdetail = lastdetail->next;
}
prev->next = newdetails;
retval = 1;
} }
gdc->details_end = newdetails;
gdc->count++; gdc->count++;
return retval; return 1;
} }
static int static int