The Git repository of the Libabigail Project
Go to file
Xiaole He 365b1b3592 abg-reader: optimize if construction
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>
2022-10-17 13:06:13 +02:00
.github Adding missing newline to build-container workflow 2022-05-17 09:46:16 +02:00
autoconf-archive Replace individual license references with SPDX Identifiers 2020-12-02 11:44:13 +01:00
bash-completion Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
doc abidiff: add a --debug-tc option 2022-10-07 22:50:14 +02:00
docker Add github actions to support workflows 2022-05-17 00:13:40 +02:00
include comparison: Ensure that fn parms with basic types can't be redundant 2022-09-22 01:46:20 +02:00
m4
relicensing-scripts Bug 27512 - Remove broken zip-archive support 2021-03-19 10:52:57 +01:00
scripts Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
src abg-reader: optimize if construction 2022-10-17 13:06:13 +02:00
tests dwarf-reader: Fix class size setting bug 2022-10-14 16:49:31 +02:00
tools abidiff: add a --debug-tc option 2022-10-07 22:50:14 +02:00
.clang-format Tweak clang-format configuration 2021-10-19 12:59:18 +02:00
.gitignore .gitignore: Add libabigail-?.* *.orig files 2019-05-22 14:34:23 +02:00
.mailmap Add '.mailmap' 2021-12-17 20:12:20 +01:00
abigail.m4 Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
ABIXML-FORMAT-VERSIONS Bug 28450 - Fix cloned member function handling in DWARF 2021-11-12 18:31:28 +01:00
AUTHORS
ChangeLog Update ChangeLog for 2.1 release. 2022-09-25 06:11:19 +02:00
COMMIT-LOG-GUIDELINES
COMPILING Improve some grammar 2022-02-25 11:24:20 +01:00
configure.ac Bump version number to 2.2 2022-09-26 08:32:32 +02:00
CONTRIBUTING Improve some grammar 2022-02-25 11:24:20 +01:00
default.abignore Re-license the project to Apache v2 With LLVM Exception 2020-12-02 11:49:13 +01:00
gen-changelog.py Replace individual license references with SPDX Identifiers 2020-12-02 11:44:13 +01:00
install-sh Replace individual license references with SPDX Identifiers 2020-12-02 11:44:13 +01:00
libabigail.pc.in
license-change-2020.txt Add a license-change-2020.txt file 2020-12-02 11:50:22 +01:00
LICENSE.txt Add the LICENSE.txt file 2020-12-02 11:49:33 +01:00
ltmain.sh Replace individual license references with SPDX Identifiers 2020-12-02 11:44:13 +01:00
Makefile.am Fix tarball upload directory 2021-10-04 16:06:43 +02:00
NEWS Update NEWS file for 2.1 2022-09-25 07:45:51 +02:00
README Improve some grammar 2022-02-25 11:24:20 +01:00
README-DOCKER.md Add github actions to support workflows 2022-05-17 00:13:40 +02:00
release-text-template.txt
update-copyright.sh Update year in copyright notice 2022-06-21 12:58:57 +02:00
VISIBILITY Improve some grammar 2022-02-25 11:24:20 +01:00

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.