Make the 'pixel and 'percent SCM symbols C++ constants.

Improves efficiency and conciseness.
This commit is contained in:
John Ralls 2021-03-11 18:13:35 -08:00
parent a94f69d6e0
commit 27670a6e98

View File

@ -623,6 +623,13 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
%} %}
%ignore GncOptionMultichoiceKeyType; %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 %{
inline SCM scm_from_multichoices (const GncMultichoiceOptionIndexVec& indexes, inline SCM scm_from_multichoices (const GncMultichoiceOptionIndexVec& indexes,
@ -681,14 +688,14 @@ wrap_unique_ptr(GncOptionDBPtr, GncOptionDB);
SCM get_scm_value(const GncOptionRangeValue<int>& option) SCM get_scm_value(const GncOptionRangeValue<int>& option)
{ {
auto val{option.get_value()}; 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)); return scm_cons(desig, scm_from_int(val));
} }
SCM get_scm_default_value(const GncOptionRangeValue<int>& option) SCM get_scm_default_value(const GncOptionRangeValue<int>& option)
{ {
auto val{option.get_default_value()}; 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)); return scm_cons(desig, scm_from_int(val));
} }