darktable-org / darktable

darktable is an open source photography workflow application and raw developer
https://www.darktable.org
GNU General Public License v3.0
9.9k stars 1.15k forks source link

conf_gen.h needs to be rewritten #9210

Closed LebedevRI closed 1 year ago

LebedevRI commented 3 years ago

Currently that single function in that file takes the longest in the whole darktable to compile. Firstly, it should be in it's own translational unit (.c) file, it should not be in a header that is included elsewhere. Secondly, it should not be what it is now. Currently it's

   // themes/usercss
   _insert_default("themes/usercss", "false");
   _insert_type("themes/usercss", "bool");
   _insert_shortdescription("themes/usercss", "modify theme with user tweaks");

   // accel/prefer_expanded
   _insert_default("accel/prefer_expanded", "false");
   _insert_type("accel/prefer_expanded", "bool");
   _insert_shortdescription("accel/prefer_expanded", "prefer expanded instances");
   _insert_longdescription("accel/prefer_expanded", "if instances of the module are expanded, ignore collapsed instances");

  <... thousands lines more ...>

It should be

struct inner {
  const char* const default;
  const char* const values;
  const char* const min;
  const char* const max;
  const char* const type;
  const char* const shortdescription;
  const char* const longdescription;
};
struct outer {
  const char* const name;
  const struct inner data;
};
static const outer initial_conf[] = {
 {"themes/usercss", (struct inner){.default = "false", .type= "bool", .shortdescription = "modify theme with user tweaks"}},
 <... hundreds entries more ...>
};

for(int i = 0; i != sizeof(initial_conf)/sizeof(initial_conf[0])) {
  const char* const name = initial_conf[i].name;
  const struct inner* data = &initial_conf[i].data;
  if(data.default)
    _insert_default(name, data.default);
  if(data.values)
    _insert_values(values, data.values);
  <...>
}
ralfbrown commented 3 years ago

AFAICT, conf_gen.h is only included from darktable.c, but I agree that it (and any other similar data definition) shouldn't be a .h.

github-actions[bot] commented 3 years ago

This issue did not get any activity in the past 30 days and will be closed in 365 days if no update occurs. Please check if the master branch has fixed it and report again or close the issue.

github-actions[bot] commented 1 year ago

This issue did not get any activity in the past year and thus has been closed. Please check if the newest release or master branch has it fixed. Please, create a new issue if the issue is not fixed.