mirror of
git://sourceware.org/git/libabigail.git
synced 2024-12-25 11:12:14 +00:00
The Git repository of the Libabigail Project
365b1b3592
In 'build_enum_type_decl' function of 'src/abg-reader.cc', the 'for loop' walk through all the child nodes of the '<enum-decl>' for seeking '<underlying-type>' and '<enumerator>': /* 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 '<enum-decl>', there involves 2 'if' comparations. Because the child node of the '<enum-decl>' is either '<underlying-type>' or '<enumerator>', 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 */ <abi-instr version='1.0'> <enum-decl name='E' filepath='../../abitests/test-enum0-v0.cc' line='1' column='6' id='type-id-2'> <underlying-type type-id='type-id-1'/> <enumerator name='e0' value='0'/> <enumerator name='e2' value='1'/> </enum-decl> </abi-instr> /* test case end */ When parsing the '<underlying-type>' 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 <hexiaole@kylinos.cn> Tested-by: Xiaole He <hexiaole@kylinos.cn> Signed-off-by: Dodji Seketeli <dodji@redhat.com> |
||
---|---|---|
.github | ||
autoconf-archive | ||
bash-completion | ||
doc | ||
docker | ||
include | ||
m4 | ||
relicensing-scripts | ||
scripts | ||
src | ||
tests | ||
tools | ||
.clang-format | ||
.gitignore | ||
.mailmap | ||
abigail.m4 | ||
ABIXML-FORMAT-VERSIONS | ||
AUTHORS | ||
ChangeLog | ||
COMMIT-LOG-GUIDELINES | ||
COMPILING | ||
configure.ac | ||
CONTRIBUTING | ||
default.abignore | ||
gen-changelog.py | ||
install-sh | ||
libabigail.pc.in | ||
license-change-2020.txt | ||
LICENSE.txt | ||
ltmain.sh | ||
Makefile.am | ||
NEWS | ||
README | ||
README-DOCKER.md | ||
release-text-template.txt | ||
update-copyright.sh | ||
VISIBILITY |
This is the Application Binary Interface Generic Analysis and Instrumentation Library. It aims at constructing, manipulating, serializing and de-serializing ABI-relevant artifacts. The set of artifacts that we are intersted is made of quantities like types, variable, functions and declarations of a given library or program. For a given library or program this set of quantities is called an ABI corpus. This library aims at (among other things) providing a way to compare two ABI Corpora (apparently the plural of corpus is copora, heh, that's cool), provide detailed information about their differences, and help build tools to infer interesting conclusions about these differences. You are welcome to contribute to this project after reading the files CONTRIBUTING and COMMIT-LOG-GUIDELINES files in the source tree. Communicating with the maintainers of this project -- including sending patches to be include to the source code -- happens via email at libabigail@sourceware.org.