tab completion optimization
This commit is contained in:
parent
621b9b0bbb
commit
8005788cd1
|
@ -81,6 +81,13 @@ Fri Sep 4 00:34:30 1992 Per Bothner (bothner@rtl.cygnus.com)
|
||||||
match "FOO". This allows 'break Foo' to work when Foo is
|
match "FOO". This allows 'break Foo' to work when Foo is
|
||||||
a mangled C++ function. (See comment before function.)
|
a mangled C++ function. (See comment before function.)
|
||||||
|
|
||||||
|
Thu Sep 3 13:44:46 1992 K. Richard Pixley (rich@sendai.cygnus.com)
|
||||||
|
|
||||||
|
* symtab.c (completion_list_add_symbol): restructured to optimize
|
||||||
|
for time. First clip names that cannot match. Then clip any
|
||||||
|
names we've already considered. Drop a redundant strncpy. Drop
|
||||||
|
a redundant malloc and associated free for demangled names.
|
||||||
|
|
||||||
Thu Sep 3 09:17:05 1992 Stu Grossman (grossman at cygnus.com)
|
Thu Sep 3 09:17:05 1992 Stu Grossman (grossman at cygnus.com)
|
||||||
|
|
||||||
* a68v-xdep.c (store_inferior_registers): Define as type void.
|
* a68v-xdep.c (store_inferior_registers): Define as type void.
|
||||||
|
|
49
gdb/symtab.c
49
gdb/symtab.c
|
@ -2482,35 +2482,50 @@ completion_list_add_symbol (symname, text, text_len)
|
||||||
{
|
{
|
||||||
char *demangled;
|
char *demangled;
|
||||||
int newsize;
|
int newsize;
|
||||||
|
int i;
|
||||||
|
|
||||||
/* First see if SYMNAME is a C++ mangled name, and if so, use the
|
/* clip symbols that cannot match */
|
||||||
demangled name instead, including any parameters. */
|
|
||||||
|
if (!cplus_match (symname, text, text_len)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* matches mangled, may match unmangled. now clip any symbol names
|
||||||
|
that we've already considered. (This is a time optimization) */
|
||||||
|
|
||||||
|
for (i = 0; i < return_val_index; ++i) {
|
||||||
|
if (strcmp (symname, return_val[i]) == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* See if SYMNAME is a C++ mangled name, and if so, use the
|
||||||
|
demangled name instead, including any parameters. */
|
||||||
|
|
||||||
if ((demangled = cplus_demangle (symname, DMGL_PARAMS | DMGL_ANSI)) != NULL)
|
if ((demangled = cplus_demangle (symname, DMGL_PARAMS | DMGL_ANSI)) != NULL)
|
||||||
{
|
{
|
||||||
|
if (strncmp (demangled, text, text_len) != 0) {
|
||||||
|
return;
|
||||||
|
} /* demangled, but didn't match so clip it */
|
||||||
|
|
||||||
symname = demangled;
|
symname = demangled;
|
||||||
|
} else {
|
||||||
|
symname = savestring (symname, strlen (symname));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If we have a match for a completion, then add SYMNAME to the current
|
/* If we have a match for a completion, then add SYMNAME to the current
|
||||||
list of matches. Note that we always make a copy of the string, even
|
list of matches. Note that the name is in freshly malloc'd space;
|
||||||
if it is one that was returned from cplus_demangle and is already
|
either from cplus_demangle or from savestring above. */
|
||||||
in malloc'd memory. */
|
|
||||||
|
|
||||||
if (strncmp (symname, text, text_len) == 0)
|
if (return_val_index + 3 > return_val_size)
|
||||||
{
|
{
|
||||||
if (return_val_index + 3 > return_val_size)
|
newsize = (return_val_size *= 2) * sizeof (char *);
|
||||||
{
|
return_val = (char **) xrealloc ((char *) return_val, newsize);
|
||||||
newsize = (return_val_size *= 2) * sizeof (char *);
|
|
||||||
return_val = (char **) xrealloc ((char *) return_val, newsize);
|
|
||||||
}
|
|
||||||
return_val[return_val_index++] = savestring (symname, strlen (symname));
|
|
||||||
return_val[return_val_index] = NULL;
|
|
||||||
}
|
}
|
||||||
|
return_val[return_val_index++] = symname;
|
||||||
|
return_val[return_val_index] = NULL;
|
||||||
|
|
||||||
if (demangled != NULL)
|
return;
|
||||||
{
|
|
||||||
free (demangled);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return a NULL terminated array of all symbols (regardless of class) which
|
/* Return a NULL terminated array of all symbols (regardless of class) which
|
||||||
|
|
Loading…
Reference in New Issue