diff options
author | mifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-01-10 19:10:55 +0000 |
---|---|---|
committer | mifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60> | 2008-01-10 19:10:55 +0000 |
commit | 64aac5f7e1f2893d88fc4fb7079829de74c41920 (patch) | |
tree | 6b63e9341f757827ab84efb27b80c5bd161e5356 | |
parent | 0160320060cab521f66ea100d67a31b0b906d35f (diff) | |
download | openocd+libswd-64aac5f7e1f2893d88fc4fb7079829de74c41920.tar.gz openocd+libswd-64aac5f7e1f2893d88fc4fb7079829de74c41920.tar.bz2 openocd+libswd-64aac5f7e1f2893d88fc4fb7079829de74c41920.tar.xz openocd+libswd-64aac5f7e1f2893d88fc4fb7079829de74c41920.zip |
- added patch for faster start of OpenOCD
(thanks to oyvind harboe for the patch)
git-svn-id: svn://svn.berlios.de/openocd/trunk@250 b42882b7-edfa-0310-969c-e2dbd0fdcd60
-rw-r--r-- | src/helper/command.c | 18 | ||||
-rw-r--r-- | src/helper/replacements.c | 1 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/helper/command.c b/src/helper/command.c index adaad109..e9ea0692 100644 --- a/src/helper/command.c +++ b/src/helper/command.c @@ -76,9 +76,15 @@ int build_unique_lengths(command_context_t *context, command_t *commands) return ERROR_OK; } +/* Avoid evaluating this each time we add a command. Reduces overhead from O(n^2) to O(n). + * Makes a difference on ARM7 types machines and is not observable on GHz machines. + */ +static int unique_length_dirty=1; + command_t* register_command(command_context_t *context, command_t *parent, char *name, int (*handler)(struct command_context_s *context, char* name, char** args, int argc), enum command_mode mode, char *help) { command_t *c, *p; + unique_length_dirty=1; if (!context || !name) return NULL; @@ -127,14 +133,13 @@ command_t* register_command(command_context_t *context, command_t *parent, char } } - /* update unique lengths */ - build_unique_lengths(context, (parent) ? parent : context->commands); - return c; } int unregister_command(command_context_t *context, char *name) { + unique_length_dirty=1; + command_t *c, *p = NULL, *c2; if ((!context) || (!name)) @@ -309,6 +314,13 @@ int find_and_run_command(command_context_t *context, command_t *commands, char * { command_t *c; + if (unique_length_dirty) + { + unique_length_dirty=0; + /* update unique lengths */ + build_unique_lengths(context, context->commands); + } + for (c = commands; c; c = c->next) { if (strncasecmp(c->name, words[start_word], c->unique_len)) diff --git a/src/helper/replacements.c b/src/helper/replacements.c index 49f12d78..7a6729b8 100644 --- a/src/helper/replacements.c +++ b/src/helper/replacements.c @@ -24,6 +24,7 @@ /* DANGER!!!! These must be defined *BEFORE* replacements.h and the malloc() macro!!!! */ #include <stdlib.h> +#include <string.h> #include <strings.h> /* * clear_malloc |