diff --git a/ChangeLog b/ChangeLog index 95be8e55690bbeb9679a20dc944f339199281291..cd1696197fac752e3a86a80b5e89b5ee502c5762 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ * src/files.c (load_poshistory): Remove some code duplication. * src/files.c (save_poshistory, update_poshistory, check_poshistory, load_poshistory): Differentiate variable name from function names. + * src/files.c (load_poshistory): Remove a senseless iteration. GNU nano 2.5.1 - 2016.01.11 diff --git a/src/files.c b/src/files.c index b06d46d4941ac09eca907a711bece9794999387d..f494a38e5047106cf4af9a8ab6ab6588ce09c235 100644 --- a/src/files.c +++ b/src/files.c @@ -3217,7 +3217,7 @@ void load_poshistory(void) char *line = NULL, *lineptr, *xptr; size_t buf_len = 0; ssize_t read; - poshiststruct *posptr, *newrecord; + poshiststruct *record_ptr = NULL, *newrecord; /* Read and parse each line, and store the extracted data. */ while ((read = getline(&line, &buf_len, hist)) >= 0) { @@ -3240,11 +3240,10 @@ void load_poshistory(void) /* Add the record to the list. */ if (position_history == NULL) position_history = newrecord; - else { - for (posptr = position_history; posptr->next != NULL;) - posptr = posptr->next; - posptr->next = newrecord; - } + else + record_ptr->next = newrecord; + + record_ptr = newrecord; } fclose(hist); free(line);