Commit 73ee7d7e authored by Benno Schulenberg's avatar Benno Schulenberg
Browse files

Removing a senseless iteration: simply add the new record at the tail.

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@5552 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
No related merge requests found
Showing with 6 additions and 6 deletions
+6 -6
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* src/files.c (load_poshistory): Remove some code duplication. * src/files.c (load_poshistory): Remove some code duplication.
* src/files.c (save_poshistory, update_poshistory, check_poshistory, * src/files.c (save_poshistory, update_poshistory, check_poshistory,
load_poshistory): Differentiate variable name from function names. 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 GNU nano 2.5.1 - 2016.01.11
......
...@@ -3217,7 +3217,7 @@ void load_poshistory(void) ...@@ -3217,7 +3217,7 @@ void load_poshistory(void)
char *line = NULL, *lineptr, *xptr; char *line = NULL, *lineptr, *xptr;
size_t buf_len = 0; size_t buf_len = 0;
ssize_t read; ssize_t read;
poshiststruct *posptr, *newrecord; poshiststruct *record_ptr = NULL, *newrecord;
/* Read and parse each line, and store the extracted data. */ /* Read and parse each line, and store the extracted data. */
while ((read = getline(&line, &buf_len, hist)) >= 0) { while ((read = getline(&line, &buf_len, hist)) >= 0) {
...@@ -3240,11 +3240,10 @@ void load_poshistory(void) ...@@ -3240,11 +3240,10 @@ void load_poshistory(void)
/* Add the record to the list. */ /* Add the record to the list. */
if (position_history == NULL) if (position_history == NULL)
position_history = newrecord; position_history = newrecord;
else { else
for (posptr = position_history; posptr->next != NULL;) record_ptr->next = newrecord;
posptr = posptr->next;
posptr->next = newrecord; record_ptr = newrecord;
}
} }
fclose(hist); fclose(hist);
free(line); free(line);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment