aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Johnson <peter@tortall.net>2013-08-07 22:11:39 -0700
committerPeter Johnson <peter@tortall.net>2013-08-07 22:15:20 -0700
commit964fd9a016a0c34525ef2a1f335a0ed44f57c550 (patch)
treefe5ef8cf59b5148c936cfc48307015b3208f9bf1
parentd8c0c39254c32fcb78343e81f8f5c87fd3d28995 (diff)
downloadyasm-964fd9a016a0c34525ef2a1f335a0ed44f57c550.tar.gz
Optimize matching loops.
Reported by: Po-Chun Chang [#264 state:resolved] [#265 state:resolved] [#266 state:resolved]
-rw-r--r--frontends/yasm/yasm.c7
-rw-r--r--libyasm/assocdat.c4
-rw-r--r--libyasm/section.c8
3 files changed, 15 insertions, 4 deletions
diff --git a/frontends/yasm/yasm.c b/frontends/yasm/yasm.c
index f070a168..76353fc6 100644
--- a/frontends/yasm/yasm.c
+++ b/frontends/yasm/yasm.c
@@ -448,9 +448,14 @@ do_assemble(void)
*/
matched = 0;
for (i=0; cur_parser_module->preproc_keywords[i]; i++)
+ {
if (yasm__strcasecmp(cur_parser_module->preproc_keywords[i],
- cur_preproc_module->keyword) == 0)
+ cur_preproc_module->keyword) == 0) {
matched = 1;
+ break;
+ }
+ }
+
if (!matched) {
print_error(_("%s: `%s' is not a valid %s for %s `%s'"), _("FATAL"),
cur_preproc_module->keyword, _("preprocessor"),
diff --git a/libyasm/assocdat.c b/libyasm/assocdat.c
index cdcda62b..56009368 100644
--- a/libyasm/assocdat.c
+++ b/libyasm/assocdat.c
@@ -87,8 +87,10 @@ yasm__assoc_data_add(yasm__assoc_data *assoc_data_arg,
/* See if there's already assocated data for this callback */
for (i=0; i<assoc_data->size; i++) {
- if (assoc_data->vector[i].callback == callback)
+ if (assoc_data->vector[i].callback == callback) {
item = &assoc_data->vector[i];
+ break;
+ }
}
/* No? Then append a new one */
diff --git a/libyasm/section.c b/libyasm/section.c
index 9242fb01..8ad7deab 100644
--- a/libyasm/section.c
+++ b/libyasm/section.c
@@ -261,10 +261,14 @@ yasm_object_create(const char *src_filename, const char *obj_filename,
* for the active object format.
*/
matched = 0;
- for (i=0; objfmt_module->dbgfmt_keywords[i]; i++)
+ for (i=0; objfmt_module->dbgfmt_keywords[i]; i++) {
if (yasm__strcasecmp(objfmt_module->dbgfmt_keywords[i],
- dbgfmt_module->keyword) == 0)
+ dbgfmt_module->keyword) == 0) {
matched = 1;
+ break;
+ }
+ }
+
if (!matched) {
yasm_error_set(YASM_ERROR_GENERAL,
N_("`%s' is not a valid debug format for object format `%s'"),