From 27670a6e98865d2b8cb6c0702b8130f6a463af06 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 11 Mar 2021 18:13:35 -0800 Subject: [PATCH] Make the 'pixel and 'percent SCM symbols C++ constants. Improves efficiency and conciseness. --- libgnucash/app-utils/gnc-optiondb.i | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/libgnucash/app-utils/gnc-optiondb.i b/libgnucash/app-utils/gnc-optiondb.i index f46446c262..88094f127a 100644 --- a/libgnucash/app-utils/gnc-optiondb.i +++ b/libgnucash/app-utils/gnc-optiondb.i @@ -623,6 +623,13 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB); %} %ignore GncOptionMultichoiceKeyType; +%ignore pixels; +%ignore percent; + +%header %{ + static const SCM pixels{(scm_from_utf8_symbol("pixels"))}; + static const SCM percent{(scm_from_utf8_symbol("percent"))}; + %} %inline %{ inline SCM scm_from_multichoices (const GncMultichoiceOptionIndexVec& indexes, @@ -681,14 +688,14 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB); SCM get_scm_value(const GncOptionRangeValue& option) { auto val{option.get_value()}; - auto desig{scm_c_eval_string(val > 100 ? "'pixels" : "'percent")}; + auto desig{val > 100 ? pixels : percent}; return scm_cons(desig, scm_from_int(val)); } SCM get_scm_default_value(const GncOptionRangeValue& option) { auto val{option.get_default_value()}; - auto desig{scm_c_eval_string(val > 100 ? "'pixels" : "'percent")}; + auto desig{val > 100 ? pixels : percent}; return scm_cons(desig, scm_from_int(val)); }