3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2025-04-24 01:25:31 +00:00

cache datatype util in context to avoid performance bug, codeplex issue 195

Signed-off-by: Nikolaj Bjorner <nbjorner@hotmail.com>
This commit is contained in:
Nikolaj Bjorner 2015-03-25 11:46:17 -07:00
parent 8059a5a0b7
commit 39892aae10
3 changed files with 14 additions and 10 deletions

View file

@ -475,12 +475,12 @@ extern "C" {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
unsigned n = dt_util.get_datatype_num_constructors(_t);
if (idx >= n) {
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
if (idx >= decls->size()) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
func_decl* decl = dt_util.get_constructor(_t, idx);
func_decl* decl = (*decls)[idx];
mk_c(c)->save_ast_trail(decl);
return of_func_decl(decl);
}
@ -505,12 +505,12 @@ extern "C" {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
}
unsigned n = dt_util.get_datatype_num_constructors(_t);
if (idx >= n) {
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
if (idx >= decls->size()) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
func_decl* decl = dt_util.get_constructor(_t, idx);
func_decl* decl = (*decls)[idx];
decl = dt_util.get_constructor_recognizer(decl);
mk_c(c)->save_ast_trail(decl);
RETURN_Z3(of_func_decl(decl));
@ -528,12 +528,12 @@ extern "C" {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);
}
unsigned n = dt_util.get_datatype_num_constructors(_t);
if (idx_c >= n) {
ptr_vector<func_decl> const * decls = dt_util.get_datatype_constructors(_t);
if (idx_c >= decls->size()) {
SET_ERROR_CODE(Z3_INVALID_ARG);
return 0;
}
func_decl* decl = dt_util.get_constructor(_t, idx_c);
func_decl* decl = (*decls)[idx_c];
if (decl->get_arity() <= idx_a) {
SET_ERROR_CODE(Z3_INVALID_ARG);
RETURN_Z3(0);