*optimized memory occupation with lambda.
This commit is contained in:
parent
82ddc8c029
commit
686be8e61a
1
HISTORY
1
HISTORY
@ -7,6 +7,7 @@ Fixed a multiple disposing bug with string expression calculation
|
||||
Improved GC with outer scopes of lambda
|
||||
Fixed some other minor bugs with lambda
|
||||
Fixed a wrong disposing bug when accessing a collection by brackets
|
||||
Optimized memory occupation with lambda
|
||||
|
||||
Jan. 11 2016
|
||||
Fixed a crash bug when a DO-UNTIL statement is the end of a program
|
||||
|
@ -6234,7 +6234,6 @@ _running_context_t* _init_lambda(mb_interpreter_t* s, _routine_t* routine) {
|
||||
lambda = &routine->func.lambda;
|
||||
lambda->scope = _create_running_context(true);
|
||||
result = _push_scope_by_routine(s, lambda->scope);
|
||||
lambda->upvalues = _ht_create(0, _ht_cmp_string, _ht_hash_string, 0);
|
||||
|
||||
return result;
|
||||
}
|
||||
@ -6301,6 +6300,8 @@ void _mark_upvalue(mb_interpreter_t* s, _lambda_t* lambda, _object_t* obj, const
|
||||
_ls_pushback(found_in_scope->refered_lambdas, lambda);
|
||||
}
|
||||
|
||||
if(!lambda->upvalues)
|
||||
lambda->upvalues = _ht_create(0, _ht_cmp_string, _ht_hash_string, 0);
|
||||
_ht_set_or_insert(lambda->upvalues, obj->data.variable->name, obj);
|
||||
}
|
||||
|
||||
@ -6422,6 +6423,7 @@ int _fill_outer_scope(void* data, void* extra, void* t) {
|
||||
_upvalue_scope_tuple_t* tuple = (_upvalue_scope_tuple_t*)t;
|
||||
mb_unrefvar(extra);
|
||||
|
||||
if(lambda->upvalues) {
|
||||
tuple->filled = _ht_create(0, _ht_cmp_intptr, _ht_hash_intptr, 0); {
|
||||
tuple->lambda = lambda;
|
||||
_HT_FOREACH(lambda->upvalues, _do_nothing_on_ht_for_lambda, _fill_with_upvalue, tuple);
|
||||
@ -6429,6 +6431,7 @@ int _fill_outer_scope(void* data, void* extra, void* t) {
|
||||
}
|
||||
_HT_FOREACH(tuple->filled, _do_nothing_on_ht_for_lambda, _remove_filled_upvalue, lambda->upvalues);
|
||||
_ht_destroy(tuple->filled);
|
||||
}
|
||||
|
||||
if(lambda->outer_scope) {
|
||||
if(tuple->outer_scope->scope != lambda->outer_scope->scope)
|
||||
|
Loading…
x
Reference in New Issue
Block a user