Changeset: d720b053e996 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=d720b053e996
Modified Files:
monetdb5/mal/mal_instruction.c
monetdb5/mal/mal_interpreter.c
Branch: Apr2019
Log Message:
Simplify code.
diffs (54 lines):
diff --git a/monetdb5/mal/mal_instruction.c b/monetdb5/mal/mal_instruction.c
--- a/monetdb5/mal/mal_instruction.c
+++ b/monetdb5/mal/mal_instruction.c
@@ -596,27 +596,20 @@ findVariable(MalBlkPtr mb, const char *n
}
/* The second version of findVariable assumes you have not yet
- * allocated a private structure. This is particularly usefull during
+ * allocated a private structure. This is particularly useful during
* parsing, because most variables are already defined. This way we
* safe GDKmalloc/GDKfree. */
int
findVariableLength(MalBlkPtr mb, str name, int len)
{
int i;
- int j;
- for (i = mb->vtop - 1; i >= 0; i--)
- {
- str s = mb->var[i].id;
+ for (i = mb->vtop - 1; i >= 0; i--) {
+ const char *s = getVarName(mb, i);
- j = 0;
- if (s)
- for (j = 0; j < len; j++)
- if (name[j] != s[j])
- break;
- if (j == len && s && s[j] == 0)
- return i;
- }
+ if (s && strncmp(name, s, len) == 0 && s[len] == 0)
+ return i;
+ }
return -1;
}
diff --git a/monetdb5/mal/mal_interpreter.c b/monetdb5/mal/mal_interpreter.c
--- a/monetdb5/mal/mal_interpreter.c
+++ b/monetdb5/mal/mal_interpreter.c
@@ -911,12 +911,10 @@ str runMALsequence(Client cntxt, MalBlkP
exceptionVar = -1;
msg = strchr(ret, ':');
if (msg) {
- *msg = 0;
exceptionVar = findVariableLength(mb, ret,
(int)(msg - ret));
- *msg = ':';
}
if (exceptionVar == -1)
- exceptionVar = findVariableLength(mb,
"ANYexception", 12);
+ exceptionVar = findVariable(mb, "ANYexception");
/* unknown exceptions lead to propagation */
if (exceptionVar == -1) {
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list