aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Marchi <simon.marchi@polymtl.ca>2025-03-24 16:20:27 -0400
committerSimon Marchi <simon.marchi@efficios.com>2025-03-25 11:32:35 -0400
commit8cbf7d2a4748b37d70323f45a378aee8a9a96f8a (patch)
treed0e385414e50ab895d3b540975937718de9fab27
parentf8297737722d63ba4a23c8df21765ab5a8368d64 (diff)
downloadbinutils-8cbf7d2a4748b37d70323f45a378aee8a9a96f8a.zip
binutils-8cbf7d2a4748b37d70323f45a378aee8a9a96f8a.tar.gz
binutils-8cbf7d2a4748b37d70323f45a378aee8a9a96f8a.tar.bz2
gdb/dwarf: remove unnecessary comparison in cooked_index_entry::compare
I believe that the `(mode == MATCH && a == munge ('<'))` part of the condition is unnecesary. Or perhaps I don't understand the algorithm. The use of "munge" above effectively makes it so that the template portion of names is completely ignored for the sake of the comparison. Then, in the condition, this: a == munge ('<') is functionally equivalent to a == '\0' If `a` is indeed '\0', and `b` is also '\0', then we would have taken the earlier branch: if (a == b) return 0; If `b` is not '\0', then we won't take this branch and we'll go into the final comparison: return a < b ? -1 : 1; So, as far as I can see, there is no case where `mode == MATCH`, where we're going to use this special `return 0`. Regression tested using the various DWARF target boards on Debian 12. Change-Id: I5ea0463c1fdbbc1b003de2f0a423fd0073cc9dec Approved-By: Tom Tromey <tom@tromey.com>
-rw-r--r--gdb/dwarf2/cooked-index.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/gdb/dwarf2/cooked-index.c b/gdb/dwarf2/cooked-index.c
index 724615f..1a2e19d 100644
--- a/gdb/dwarf2/cooked-index.c
+++ b/gdb/dwarf2/cooked-index.c
@@ -122,11 +122,8 @@ cooked_index_entry::compare (const char *stra, const char *strb,
/* When completing, if STRB ends earlier than STRA, consider them as
equal. */
- if (mode == COMPLETE || (mode == MATCH && a == munge ('<')))
- {
- if (b == '\0')
- return 0;
- }
+ if (mode == COMPLETE && b == '\0')
+ return 0;
return a < b ? -1 : 1;
}