Thank you for reviewing. At 2022-10-17 22:14:35, "Dodji Seketeli" wrote: >Hello Xiaole, > >Xiaole He via Libabigail a ¨¦crit: > >> In 'build_enum_type_decl' function of 'src/abg-reader.cc', the >> 'for loop' walk through all the child nodes of the '' for >> seeking '' and '': >> >> /* original src/abg-reader.cc begin */ >> static enum_type_decl_sptr >> build_enum_type_decl(read_context& ctxt, >> const xmlNodePtr node, >> bool add_to_current_scope) >> { >> ... >> for (xmlNodePtr n = xmlFirstElementChild(node); >> n; >> n = xmlNextElementSibling(n)) >> { >> if (xmlStrEqual(n->name, BAD_CAST("underlying-type"))) >> { >> ... >> } >> >> if (xmlStrEqual(n->name, BAD_CAST("enumerator"))) >> { >> ... >> } >> } >> ... >> } >> /* original src/abg-reader.cc end */ >> >> Here uses 2 separate 'if' statements for seeking, that is, for any >> child node of the '', there involves 2 'if' comparations. >> Because the child node of the '' is either >> '' or '', there would be a slight >> optimization when use 'if-else if' construction instead, like below: >> >> /* optimized src/abg-reader.cc begin */ >> for (xmlNodePtr n = xmlFirstElementChild(node); >> n; >> n = xmlNextElementSibling(n)) >> { >> if (xmlStrEqual(n->name, BAD_CAST("underlying-type"))) >> { >> ... >> } >> else if (xmlStrEqual(n->name, BAD_CAST("enumerator"))) >> { >> ... >> } >> } >> /* optimized src/abg-reader.cc end */ >> >> Supposing there has the test case: >> >> /* test case begin */ >> >> >> >> >> >> >> >> /* test case end */ >> >> When parsing the '' xml tag, for the original >> 'src/abg-reader.cc', there involves 2 'if' comparations. But involves >> only 1 'if' comparation for the optimized 'src/abg-reader.cc'. >> >> Signed-off-by: Xiaole He >> Tested-by: Xiaole He > >Applied to the master branch. > >Cheers, > >-- > Dodji