On Thu 23 Apr 2015, Emil Velikov wrote: > On 22 April 2015 at 19:03, Frank Henigman <fjhenig...@google.com> wrote: > > Use the new WAFFLE_ENUM_LIST macro to implement waffle_enum_to_string() > > instead of specifying all the enums again. > > Now it will no longer be necessary to update waffle_enum_to_string() > > when adding an enum. > > Use bsearch() instead of a case statement, not because it's better, > > but to be symmetric with a new waffle_string_to_enum() function. > > > > Signed-off-by: Frank Henigman <fjhenig...@google.com> > > --- > > src/waffle/core/wcore_util.c | 94 > > ++++++++++++++++++++++---------------------- > > 1 file changed, 47 insertions(+), 47 deletions(-)
> > +static void > > +enum_sort() > > +{ > > + static bool sorted = false; > > + if (sorted) > > + return; > > + qsort(enum_map_value, ARRAY_SIZE(enum_map_value), > > sizeof(enum_map_value[0]), > > + enum_cmp_value); > > + sorted = true; > > +} > > + > FWIW I think that this is not something anyone should do at runtime. > Regardless if we manually edit the list or generate it via the > preprocessor/python script we can (and we should) sort it there. I agree with Emil. The sorting should be done during compiletime. _______________________________________________ waffle mailing list waffle@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/waffle