diff options
author | Tom Tromey <tom@tromey.com> | 2024-04-11 20:00:09 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2024-05-14 13:28:39 -0600 |
commit | 25113e2d040fad868409c3e17262ee007fc8658a (patch) | |
tree | fd092ff1e32437aa4a714e341d78a50391fd1fcf | |
parent | 843d1820007ce64f5a69a64102a6607dcff2ce27 (diff) | |
download | gdb-25113e2d040fad868409c3e17262ee007fc8658a.zip gdb-25113e2d040fad868409c3e17262ee007fc8658a.tar.gz gdb-25113e2d040fad868409c3e17262ee007fc8658a.tar.bz2 |
Remove some unnecessary allocations from cpname_state::parse_number
cpname_state::parse_number allocates nodes for various types and then
only uses one of them. This patch reduces the number of allocations
by not performing the unnecessary ones.
Approved-By: John Baldwin <jhb@FreeBSD.org>
-rw-r--r-- | gdb/cp-name-parser.y | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/gdb/cp-name-parser.y b/gdb/cp-name-parser.y index e0b34aa..b254d63 100644 --- a/gdb/cp-name-parser.y +++ b/gdb/cp-name-parser.y @@ -1290,8 +1290,6 @@ cpname_state::parse_number (const char *p, int len, int parsed_float, /* Number of "L" suffixes encountered. */ int long_p = 0; - struct demangle_component *signed_type; - struct demangle_component *unsigned_type; struct demangle_component *type, *name; enum demangle_component_type literal_type; @@ -1362,25 +1360,26 @@ cpname_state::parse_number (const char *p, int len, int parsed_float, if (long_p == 0) { - unsigned_type = make_builtin_type ("unsigned int"); - signed_type = make_builtin_type ("int"); + if (unsigned_p) + type = make_builtin_type ("unsigned int"); + else + type = make_builtin_type ("int"); } else if (long_p == 1) { - unsigned_type = make_builtin_type ("unsigned long"); - signed_type = make_builtin_type ("long"); + if (unsigned_p) + type = make_builtin_type ("unsigned long"); + else + type = make_builtin_type ("long"); } else { - unsigned_type = make_builtin_type ("unsigned long long"); - signed_type = make_builtin_type ("long long"); + if (unsigned_p) + type = make_builtin_type ("unsigned long long"); + else + type = make_builtin_type ("long long"); } - if (unsigned_p) - type = unsigned_type; - else - type = signed_type; - name = make_name (p, len); lvalp->comp = fill_comp (literal_type, type, name); |