Optimize list appends O(n^2)->O(n)
This commit is contained in:
@@ -12,11 +12,12 @@
|
||||
struct ucl_object *ucl_evaluate_builtin_form(struct ucl_scope *scope, struct ucl_object *list) {
|
||||
// TODO: Reasonably split builtin and non-builtin evaluation
|
||||
struct ucl_object *evaluated_list = ucl_nil_create();
|
||||
struct ucl_object *evaluated_list_tail = evaluated_list;
|
||||
|
||||
FOREACH_LIST(list, iter, item) {
|
||||
struct ucl_object *obj = ucl_evaluate(scope, item);
|
||||
UCL_RET_IF_ERROR(obj);
|
||||
ucl_list_append(evaluated_list, obj);
|
||||
evaluated_list_tail = ucl_list_append(evaluated_list_tail, obj);
|
||||
};
|
||||
|
||||
struct ucl_object *fun = ucl_car(evaluated_list);
|
||||
|
||||
Reference in New Issue
Block a user