gnucash stable: Bug 798810 - Income Statement (multicolumn) - account sorting is...

John Ralls jralls at code.gnucash.org
Fri Mar 31 19:46:14 EDT 2023


Updated	 via  https://github.com/Gnucash/gnucash/commit/634b9f87 (commit)
	from  https://github.com/Gnucash/gnucash/commit/a2098b38 (commit)



commit 634b9f87449f2253131169bf6b142385d26974e1
Author: John Ralls <jralls at ceridwen.us>
Date:   Fri Mar 31 16:43:42 2023 -0700

    Bug 798810 - Income Statement (multicolumn) - account sorting is...
    
    'reversed' each time you restart.
    
    Lists read from the front, vectors to the back, so reverse the
    vector after loading it.
    
    While we're at it reserve enough elements to hold the list.

diff --git a/bindings/guile/gnc-optiondb.i b/bindings/guile/gnc-optiondb.i
index 0740947c80..ee443782ff 100644
--- a/bindings/guile/gnc-optiondb.i
+++ b/bindings/guile/gnc-optiondb.i
@@ -466,6 +466,9 @@ scm_to_value<GncOptionAccountList>(SCM new_value)
     GncOptionAccountList retval{};
     if (scm_is_false(scm_list_p(new_value)) || scm_is_null(new_value))
         return retval;
+
+    retval.reserve(scm_to_size_t(scm_length(new_value)));
+
     auto next{new_value};
     while (!scm_is_null(next) && scm_car(next))
     {
@@ -491,6 +494,8 @@ scm_to_value<GncOptionAccountList>(SCM new_value)
         }
         next = scm_cdr(next);
     }
+
+    std::reverse(retval.begin(), retval.end());
     return retval;
 }
 



Summary of changes:
 bindings/guile/gnc-optiondb.i | 5 +++++
 1 file changed, 5 insertions(+)



More information about the gnucash-changes mailing list